RE: CDOEXM and VB.Net CreateMailbox error

From: dlatoure (dlatoure_at_discussions.microsoft.com)
Date: 02/16/05


Date: Wed, 16 Feb 2005 06:09:15 -0800

I tried your code but it didn't work. It errors out in fun Logon on the
Logon = ReturnString. It then goes to CannotLogon. Here is the error
messages. The first is with your code. The second I modified the LDAP
string to match our homemdb.

"Error Logon->The server is not operational. @
12..LDAP://MAIL/cn=users,dc=unet1,dc=ad,dc=army,dc=mil..<user>.<password>

"Error Logon->The server is not operational. @ 12..LDAP://MAIL/CN=Mailbox
Store GENERAL Users (MAIL),CN=First Storage Group,
CN=InformationStore,CN=MAIL,CN=Servers,CN=Germany,CN=Administrative
Groups,CN=ARMY,CN=Microsoft Exchange,CN=Services,
CN=Configuration,dc=ad,dc=army,dc=mil..<user>.<password>

I don't know why it fails. The user account has mailbox admin rights.

"GG" wrote:

> I can get you halfway there.
>
> Const ADS_SECURE_AUTHENTICATION = 1
>
> Private Function Logon(ExchangeServer As String, Domain As String, AdmUser
> As String, AdmPassword As String, ByRef dso As IADsOpenDSObject, ByRef
> ActiveDirectory As IADsContainer)
>
> Dim LDAPString As String
> Dim ReturnString As String
>
> On Error GoTo CannotLogon
> 10: LDAPString = "LDAP://" + ExchangeServer + "/cn=users" +
> GetDCString(Domain)
> 11: Set dso = GetObject("LDAP:")
> 12: Set ActiveDirectory = dso.OpenDSObject(LDAPString, AdmUser,
> AdmPassword, ADS_SECURE_AUTHENTICATION)
> GoTo AtEnd
>
> CannotLogon:
> ReturnString = "Error Logon->" + Err.Description + " @ " + CStr(Erl) +
> ".." + LDAPString + ".." + AdmUser + "." + AdmPassword
> Resume AtEnd
>
> AtEnd:
> On Error GoTo 0
> Logon = ReturnString
>
>
> End Function
>
>
> Private Function FindUser(ByRef ActiveDirectory As IADsContainer, ByRef Usr
> As IADsUser, PrideId As String)
>
> Dim OK As Boolean
>
> On Error GoTo CannotCreate
> Set Usr = ActiveDirectory.GetObject("user", "CN=" & UCase(PrideId))
> OK = True
> GoTo AtEnd
>
> CannotCreate:
> OK = False
> Resume AtEnd
>
> AtEnd:
> On Error GoTo 0
> FindUser = OK
>
> End Function
>
> Use Logon to connect to Active Directory, then pass ActiveDirectory As
> IADsContainer to FindUser.
>
> This will return the user. The equivalent of your
>
> objADSIUser = GetObject(ADSIUserPath)
>
> Once you have done this, the rest of your code should work provided you have
> a version of ActiveDS and a version of CDOEXM that are compatible.
>
> This works for me on my live server running Exchange 2000 and Windows 2000
> Advanced Server. It also works when I call my test server running Exchange
> 2003 from my live server (The executable is running on the live server); but,
> it does not work for me when I run it directly on the test server running
> Exchange 2003.
>
> If you run into this incompatibility, you will get a "Type Mismatch" error
> when you call :
> Set objMailbox = ADSIUser
>
> The issue here is a QI problem between the two interfaces (CDOEXM and
> ActiveDS). If you run into this and you find a way to solve the
> incompatibility between these two files, please post your solution here.
>
> Thanks
>
>
> "dlatoure" wrote:
>
> > I am trying to create a user mailbox using the following code:
> >
> > Function CreateCDOEXMailBox(ByVal ADSIUserPath As String, _
> > ByVal DCServer As String, ByVal DomainName As String) As Boolean
> > Dim objMailbox As CDOEXM.IMailboxStore
> > Dim objADSIUser As ActiveDs.IADsUser
> >
> > Try
> > 'Bind User to AD
> > objADSIUser = GetObject(ADSIUserPath)
> > objMailbox = objADSIUser
> > objMailbox.CreateMailbox("LDAP://" & DCServer & "/" & _
> > "CN=Mailbox Store GENERAL Users (MAILSRV)," & _
> > "CN=First Storage Group," & _
> > "CN=InformationStore," & _
> > "CN=" & DCServer & "," & _
> > "CN=Servers," & _
> > "CN=Site," & _
> > "CN=Administrative Groups," & _
> > "CN=ORG," & _
> > "CN=Microsoft Exchange," & _
> > "CN=Services," & _
> > "CN=Configuration," & DomainName)
> > objADSIUser.SetInfo()
> > Return True
> > Catch exceptionEX As System.Exception
> > Throw exceptionEX
> > End Try
> >
> > End Function
> >
> > The ADSIUserPath being passed in comes from the user creation code in the
> > section above. It's user.path.tostring. The user account is created.
> >
> > On the objADSIUser.SetInfo() line the code throws an exception. I get a
> > CDOException with the line 'The server is not operational.'
> >
> > The user that I'm running the code under can create mailboxes from the GUI.
> > The LDAP string that I'm using is identical to another user's homemdb string.
> > Is the homemdb string the same as the homemdburl?
> >
> > Any help appreciated. Thank you



Relevant Pages

  • Re: VB NetAPI User Account Validation
    ... LogonUser does a local logon for a user. ... > (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal ... > rtn = NetUserChangePassword(StrConv(Domain, vbUnicode), StrConv(UserName, ...
    (microsoft.public.vb.winapi)
  • RE: Adding Groups on the basis of text in a VBScript
    ... Firstly we need to read multiple text files, which are acting as logon ... If the Datalink string is present the filename of the file being read should ... > WScript.Echo " You are a member of Domain Admins " ... >> scripts which utilize vbscript. ...
    (microsoft.public.windows.server.scripting)
  • Falsche Laufwerkszuordnung =?ISO-8859-15?Q?f=FCr_logon_drive?=
    ... server string = PDC ... logon script = %U.cmd ... ldap delete dn = Yes ... # directive and/or disable roaming profiles ...
    (de.comp.os.unix.networking.samba)
  • Re: Newbie VB .NET: Determine length of string
    ... >> form with the username portion of the logon value. ... I realize you can not define a string as a fixed length field but I ... > String gives the length of the string, or you could split on backslash ...
    (microsoft.public.dotnet.framework.windowsforms)