problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003
From: galliumxe (showkase2002_at_yahoo.com)
Date: 03/04/04
- Next message: Morley Lee: "Encrypting email"
- Previous message: Mark Hewitson: "Fax software with Exchange"
- Next in thread: Andy Webb: "Re: problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003"
- Reply: Andy Webb: "Re: problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003"
- Messages sorted by: [ date ] [ thread ]
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();
- Next message: Morley Lee: "Encrypting email"
- Previous message: Mark Hewitson: "Fax software with Exchange"
- Next in thread: Andy Webb: "Re: problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003"
- Reply: Andy Webb: "Re: problems creating (enabling) an exchange mailbox using cdoexm on exchange 2003"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|