createMailbox "unspecified error"

flanderp

Member
Joined
Aug 30, 2006
Messages
9
Programming Experience
Beginner
Hi,

Hope that I am posting this in the correct place:-s

I have a problem with some code I wrote a while ago which imports students from an oracle database and creates the users account within Active Directory. For some reason the code has stopped working and when I debug the code It always fails on the createmailbox with error “unspecified error”.

Here is the section of my code

1 Dim ldapq AsString = GetUsersOU(username)
2 Dim user AsNew DirectoryEntry("LDAP://" & ldapq)
3 Dim mbx As IMailboxStore = user.NativeObject
4 try
5 mbx.CreateMailbox(RandomStorageGroup(acctype))

' RandomStorageGroup would =

"CN=Staff 1,CN=SG1,CN=InformationStore,CN=TEL-EXCH01,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=TCAT,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tcat,DC=network"

6 user.CommitChanges()
7 sendWelcomeMessage(username, acctype)
8 catch ex as exception
9 dim message as string = ex.message
10 end try


The only thing that I can think of is that our exchange servers had the updates and security hot fix's applied about the time mbx.createmailbox started failing. I have stared at it for hours and can not see what’s going wrong.

Any Ideas ?

Thanks
Paul
 
CDO.Person

Hi,

Thanks for the reply, I am using the examples from the 2nd (Microsoft) link you posted , but having a problem with the syntax

CDO.Person

I can not see in the article what I need to ref so guessed and added the line

Imports CDO

But Person isnt listed under CDO

Any idea's?

Thanks again

Paul
 
I should have metioned this bit you need to run regsvr32 on cdoex.dll. That should sort things out.


EDIT: You may have to run it on these as well...

cdo.dll, cdoexm.dll
 
Last edited:
Still having problems :-(

hi,

After running regsvr32 on the 3 dlls the CDO.Person became available (thanks) so I have read through the article and come up with the following code.
VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ReadOnly[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE][SIZE=2] CreateExchangeAccount([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] username [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] acctype [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=seagreen]' Pass in the username and acctype username=paul, acctype=staff[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oPerson [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CDO.Person[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oMailbox [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] CDOEXM.IMailboxStore[/SIZE]
 
[SIZE=2]oPerson.DataSource.SaveTo("LDAP://" & GetUsersOU(username))[/SIZE]
[SIZE=2][COLOR=seagreen]' GetUsersOU(username) will return the users OU path eg, CN=paul,OU=Staff,DC=hub,DC=tcat,DC=network"[/COLOR][/SIZE]
[SIZE=2]oMailbox = oPerson[/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]oMailbox.CreateMailbox(RandomStorageGroup(acctype))[/SIZE]
[SIZE=2][COLOR=seagreen]' RandomStorageGroup(acctype=staff) would return [/COLOR][/SIZE]
[SIZE=2][SIZE=2][COLOR=seagreen]CN=Staff 1,CN=SG1,CN=InformationStore,CN=TEL-EXCH01,CN=Servers,CN=First [/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=seagreen]Administrative Group,CN=Administrative Groups,CN=TCAT,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=tcat,DC=network"[/COLOR][/SIZE]
oPerson.DataSource.Save()
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] message [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = ex.Message[/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]sendWelcomeMessage(username, acctype)[/SIZE]
[SIZE=2]oPerson = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]oMailbox = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE]
The code now fails on line
oPerson.DataSource.SaveTo("LDAP://" & GetUsersOU(username))

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in tcatlibs.dll
Additional information: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Again Im stuck

This is annoying this code worked fine until a server patch update !! Now I have hundreds of accounts waiting to be created.

I noticed the 3 dll's had a higher version number on the exchange server so I ran exchange service pack 2 on my dev pc which has the exchange client tools installed , this seems to have updated the 3 dll's to the same version , but that didnt solve the problem.


Thanks
Paul





Edit :

Found this link for the error message

http://support.microsoft.com/kb/269495/EN-US/

I have gone through the resolutions but the reg key already exists

Paul

 
Last edited by a moderator:
Bit more info

The entire program consists of a module and a class the class (tcatlibs) holds all of the common functions including the above

CreateExchangeAccount(ByVal username AsString, ByVal acctype AsString) ' Returns true or false as bool

tcatlibs is then added as a reference and declared in module 1

module1 calls the exchange function with the following

If tcatlibs.CreateExchangeAccount(username, "Staff") = TrueThen
' do somthing
else
' do somthing else
end if

Edit : It is the 'createexchnageaccount' function that I am calling in tcatlibs. My students already have accounts they request email accounts via the intranet if and when they want one, the intranet posts to a db and its marked as pending , this script then looks in the db for mail accounts (among other things) that need creating it then creates and marks the record as Activated. By using the DB i thought that if the exchange create part failed then they would just stack up until it was fixed (which is whats happening at the moment)



Hope that makes sense ? I do it this way so that I can use tcatlibs in most of my other applications reusing the functions already written.

thanks
Paul
 
Last edited:
VB.NET:
oPerson.DataSource.SaveTo("LDAP://" & [COLOR=blue]GetUsersOU(username))[/COLOR]


So your function in the saveto method sets all the field for that user? As in...

VB.NET:
Operson.Fields(SomeField) = SomeValue


Then you would normally update the fields..

VB.NET:
OPerson.Fields.Update

Then you would normally use the SaveTo method.
 
ahh

maybe this is where im going wrong the getusersOU(username) simply returns eg

CN=paul,OU=Staff,DC=hub,DC=tcat,DC=network


It doesnt set anything , the users ad account is already fully populated when i read the MS example they used a sub called CreateUserURL when i looked at the sub the rem statments said


'//Purpose: To create a URL for a user
'// Parameters:
'// strUrl [out] : Returns the URL for the user or container. For example:
'// ldap://subdomain.example.com/CN=User2,CN=Users,DC=subdomain,
'// DC=example,DC=com

Looking at that now i am missing the first section 'subdomain.example.com/' so i will sort that out.

Edit : No, just tried that by changing the following

oPerson.DataSource.SaveTo("LDAP://" & GetUsersOU(username))

to

oPerson.DataSource.SaveTo("LDAP://hub.tcat.network/" & GetUsersOU(username))

Thanks
Paul
 
Last edited:
given up

Tried everything

Going to open a ticket with Microsoft, the code worked for a year and after patching and updating AD and Exchange it stopped working I will update this post when I get a solution.

Thanks
Paul
 
Back
Top