Problem Creating MailBox with CDOEXM ....

Problem Creating MailBox with CDOEXM ....

Post by Fernand » Wed, 13 Jun 2001 03:07:33



I want to creat a User in Windows 2000 Active Directory with a Exchange 2000
mailbox using ASP.
When I execute this ASP page I receive an error that I can't access Exchange
resource in active Directory at the line " objMailbox.CreateMailbox
MailBoxPath " .
The problem is that the IUSR_MachineName has no access to the Active
Directory objects.
First, when I created the user in AD I used the OpenDSObject method that
permit to connect LDAP with another user like Administrator. But when I open
the same object LDAP with CDOEXM I can't specify the user name and password
for the connection.
I try to put this information in DataSource.Open , , , , , , username , pwd
but I can't access anyway ...

Now , I set a virtual folder in IIS with Admin privileges and when I execute
this page in this folder it works. But I don't want to keep this solution.
Do You Have any other solution ?

Thanks , Fernando.

 <%

 Set ADSObject = GetObject("LDAP:")
 Set UsersObject = ADSObject.OpenDSObject
("LDAP://Netspeed/CN=Users,DC=NetforMoney,DC=Intranet" , "Administrator" ,
"xxxxx" , ADS_SECURE_AUTHENTICATION)

 nomeOggetto = "CN=" + emailname

' Delete User if exists
UsersObject.Delete "user", nomeOggetto

 ' Create user in Active Directory
 ' ------------------------------
 Set usr = UsersObject.Create("user", nomeOggetto )
 usr.Put "givenName" , FirstName
 usr.Put "Sn" , LastName
 usr.Put "samAccountName", "UserSam"
 usr.Put "userAccountControl", UF_NORMAL_ACCOUNT
 usr.Put "userPassword" , "xxxx"
 usr.SetInfo

 ' Now, create mailbox in specified location.
 '----------------------------------------

 PercorsoLDAP = "LDAP://" + "Netspeed" + _
                            "/CN=" + emailname + _
                            ",CN=Users," + domainDN

 Set objPerson = CreateObject("CDO.Person")

 Set Conn   = CreateObject("ADODB.Connection")
 Conn.Provider = "ExOLEDB.DataSource"

 objPerson.DataSource.Open PercorsoLDAP , Conn , adModeReadWrite

 Set objMailbox = objPerson.GetInterface("IMailboxStore")

 MailBoxPath = "LDAP://" + _
                         ServerName + _
                         "/CN=" + _
                         StoreName + _
                         ",CN=" + _
                         StorageGroup + ",CN=InformationStore,CN=" + _
                         "NETSPEED" + _
                         ",CN=Servers,CN=" + _
                         AdminGroup + "," + _
                         "CN=Administrative Groups,CN=" + _
                         ExchangeOrg + "," + _
                         "CN=Microsoft Exchange,CN=Services," + _
                         "CN=Configuration," + domainDN

 objMailbox.CreateMailbox MailBoxPath

 objPerson.DataSource.Save

%>