problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003

From: galliumxe (showkase2002_at_yahoo.com)
Date: 03/04/04


Date: 3 Mar 2004 20:33:51 -0800

Hello

Please help. I'm having a little trouble creating (enabling) a users
mailbox after creating their account in active directory from an ASP
webpage.

I'm using an ASP component I've built using C++. My webserver is on a
windows 2003 server with exchange management tools(machine A) and my
exchange server is 2003 (machine B) and my domain controller is also
windows 2003 (machine C).

The problem I'm having is after I create the user account in active
directory and then try to enable the mailbox, I get the following
error: HResult: -2147024809
(80070057).
It fails when calling the CreateMailbox method in my c++ code.

I did get this to work using windows 2000/ exchange 2000 /ASP - web
server all on one machine.

Can someone please tell me what changes I would need to make to my
code or environment in order to get the mailbox creation to work.
Thanks in Advance.

I created a domain user which the web server uses for all anonymous
connections. This user also belongs to the exchange admins group.

Here is the C++ code I used:

variable values from my ASP page:
userMailBoxDB = "CN=Mailbox Store (MYEXCHANGESERVER),CN=First Storage
Group,CN=InformationStore,CN=MYEXCHANGESERVER,CN=Servers,CN=First
Administrative Group,CN=Administrative Groups,CN=myOrg,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=mydomain,DC=com"

userID = "userID"
useremail = "userID@mydomain.com"
password = "userpassword"
userCN = "cn=userID"

securityaccountPassword= "DCadminpassword"
securityaccountUser= "cn=DCadmin, cn=users, dc=mydomain, dc=com"

UserBaseDN = "LDAP://myDCserver.mydomain.com/cn=users, DC=mydomain,
DC=com"

finally the C++ code:
        CoInitialize(NULL);
        
        USES_CONVERSION;
 
        HRESULT hr;
        HRESULT hr2;

        IDispatch *pDisp=NULL;
        IDirectoryObject *pDirObject=NULL;
        IADsUser *pIADsUser=NULL;
        

        ADSVALUE sAMValue;
        ADSVALUE uPNValue;
        ADSVALUE classValue;
        ADSVALUE controlValue;
        ADSVALUE DescValue;

        ADS_ATTR_INFO attrInfo[] =
        {
                {L"objectClass", ADS_ATTR_UPDATE,
                                    ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
                {L"sAMAccountName", ADS_ATTR_UPDATE,
                            ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
                {L"userPrincipalName", ADS_ATTR_UPDATE,
                                                ADSTYPE_CASE_IGNORE_STRING, &uPNValue, 1},
                {L"userAccountControl", ADS_ATTR_UPDATE, ADSTYPE_INTEGER,
&controlValue, 1},

                {L"description", ADS_ATTR_UPDATE,
                        ADSTYPE_CASE_IGNORE_STRING, &DescValue, 1}
        };

        DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
 
        classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
        classValue.CaseIgnoreString = L"user";
 
        sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
        sAMValue.CaseIgnoreString = UserID;
 
        uPNValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
        uPNValue.CaseIgnoreString = Useremail;
 
        controlValue.dwType = ADSTYPE_INTEGER;
        controlValue.Integer=UF_NORMAL_ACCOUNT | UF_PASSWD_NOTREQD |
UF_MNS_LOGON_ACCOUNT;

        DescValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
        DescValue.CaseIgnoreString = L"mydomain user";

        hr = ADsOpenObject(userBaseDN, securityaccountUser,
securityaccountPassword, ADS_SECURE_AUTHENTICATION|ADS_SERVER_BIND,
                                           IID_IDirectoryObject, (void**) &pDirObject );
        
        if ( SUCCEEDED(hr) )
        {
                hr = pDirObject->CreateDSObject( UserCN, attrInfo, dwAttrs, &pDisp
);
                if ( SUCCEEDED(hr) )
                {
                        hr = pDisp->QueryInterface( IID_IADsUser, (void**) &pIADsUser );

                        hr = pIADsUser->SetPassword(UserPassword);
                        
                        /**** CREATE A MAILBOX FOR THE NEW USER ****/
                
                                IMailboxStore *pStore = NULL;
                
                                hr = pIADsUser->QueryInterface(IID_IMailboxStore, (void**)
&pStore);
                        
                                hr = pStore->CreateMailbox( userMailBoxDB );
                                
                                pStore->Release();
                                                
                        hr = pIADsUser->SetInfo();

                        
                        pIADsUser->Release();
                        pDisp->Release();
                        
                }
                
                pDirObject->Release();
                
        }
        
        CoUninitialize();



Relevant Pages

  • Re: SQL Mail failure
    ... server has been upgraded. ... 0x80070005 If you log into the mailbox on the SQL Server server by using ... Also, using a Microsoft Exchange 5.5 mailbox, instead of a Microsoft ... Windows 2000 Active Directory. ...
    (microsoft.public.sqlserver.xml)
  • LDAP Not Usable in 2003 Environment ??
    ... I am VERY new to Active Directory, ... I currently have a successfully working test of an ASP page using LDAP ... our Exchange 5.5 server will soon become Exchange ...
    (microsoft.public.exchange.connectivity)
  • RE: exchange 5.5 and 2003 in mixed mode
    ... account reflecting the 2003 server to which the mailbox has been moved? ... the weird thing is when you move back the mailbox to 5.5, ... do you know if I can see the exchange attribute of each user with ADSI EDIT? ... Active Directory too, it will fail, with a message like the one you've copied ...
    (microsoft.public.exchange.setup)
  • RE: Event ID 3011
    ... recipient such as homeMDB/msExchHomeServerName (the Exchange server on ... the recipients mailbox resides) might be missing or corrupted. ... Check the user directory attributes integrity in Active Directory ...
    (microsoft.public.exchange2000.transport)
  • Problems Creating a Mailbox
    ... I am using Exchange 2000 servers, our Active Directory is running a mix of Windows 2000 and Windows 2003 servers for the domain controllers, and our clients are running Windows XP. ... Our admin machines have the Windows Server 2003 SP1 admin pack installed, along with the Exchange Server 2003 System Manager console installed. ... When Active Directory Users and Computers is connected to a domain controller running Windows Server 2003, when we get to the step to create an Exchange mailbox, the drop down box that is supposed to list the available Mailbox Stores is completely empty. ...
    (microsoft.public.exchange2000.admin)

Loading