Question Need help. Move an exchange mailbox in exchange 2003

elfranger

New member
Joined
Nov 13, 2008
Messages
4
Programming Experience
Beginner
Greetings and salutations. I am working on a vb.net windows application that will search AD and find all disabled accounts who's mailbox is on a specified server. Application shows a list of all exchange servers and selection populates the LDAP search parameters. All this is working fine, it is just when it comes to actually moving the mailbox it fails with some weird results.

The mailboxes I want to move belongs to accounts that are disabled, and some will have the "msExchHideFromAddressLists" set to True...

So, I have come up with this function, and I pass the user's distinguishedname to it:

VB.NET:
Function Movemailbox(ByVal distinguishedname As String)
        Try
            Dim ldapstring As String
            ldapstring = "LDAP://" & distinguishedname
            Dim objuser As DirectoryEntry = New DirectoryEntry(ldapstring)
            Dim objmailbox As CDOEXM.IMailboxStore = objuser.NativeObject
            objmailbox.MoveMailbox("LDAP://CN=<mailstore>,CN=<storagegroup>,CN=InformationStore,CN=<server>,CN=Servers,CN=<admin group>,CN=Administrative Groups,CN=<organisation>,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=<domain>,DC=com")
            objuser.CommitChanges()

        Catch ex As System.Exception
            MessageBox.Show("Error: " & ex.ToString)
        End Try
     End Function

What happens is that it seems to connect ok to the object, but generates a catastrophic failure.

System.Runtime.InterOpServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) at CDOEXM.IMailBoxStore,MoveMailbox(String HomeMDBURL)

The weird thing is, that if I manually enter my own distinguishedname (or any other live account, it works fine.

Does anyone have any ideas, as I am pretty lost...
 
Last edited:
I have resolved this. It helps to consult the eventlog from time to time as it gave me the answer ;-).

While vb.net gives me catastrophic failure, the eventlog gives me a CDOEXM error saying 1. I do not have permissions to log on and 2. Unable to initialize MAPI32.DLL.

Is there any way I can get that into the application and write it to the logfile?

To make it work I had to move away from impersonation within the code as I got in trouble with initialising MAPI then. So, fired up visual studio using the service account and then it worked fine.

The finished application will be run under the same service account, so I don't think i need any impersonation within the code.

:)
 
Last edited:
Back
Top