|
 |
asp_cdo thread: How to create an email account on Exchange server using ASP, ADSI?
Message #1 by xuejunca@y... on Mon, 29 Oct 2001 16:46:54
|
|
Hi Everyone:
I want to create an E-mail account on Exchange 2000 server. I keep
getting error on the following code. I have marked where the errors are.
Can anyone help me out on this please?
IF you do not have patiance to finish reading what I wrote, it will be
greatly appriciated if you can send me your own code. Thanks a lot in
advance.
<%
'First of all, get authenticated on this server.
Dim ADsPath
Dim pwd
Dim uid
Dim flags
ADsPath = "LDAP://itads.itdev.lab/ou=test users,dc=itdev,dc=lab"
uid = "MyID"
pwd = "MyPassword"
flags = 0
Dim ADsNameSpace
Set ADsNameSpace = GetObject("LDAP:")
Dim oADsObject
set oADsObject = ADsNameSpace.OpenDSObject( ADsPath, uid, pwd, flags )
If err.number = 0 Then
Response.Write("Login Was Successful: " & uid)
Else
Response.Write("Login Failed: " & uid)
Response.Write(err.number)
Response.Write(err.description)
End If
' Here I am going to create a user account
Dim userObj
set userObj = oADsObject.Create("user", "cn=JackyZhang")
userObj.Put "samAccountName","NewJacky"
userObj.Put "userPrincipalName", "Jacky"
userObj.Put "givenName", "Jacky"
userObj.Put "sn", "Zhang"
userObj.Put "DisplayName", "Jackyz@c..."
userObj.Put "mail", "Jackyz@c..."
userObj.SetInfo
userObj.ChangePassword "", "myPassword"
userObj.AccountDisabled = False
userObj.SetInfo
' Now to create a mailbox
Dim ObjMailbox
set ObjMailbox = userObj
Response.write("<font color='Blue'>" & objMailbox.Class & "---</font>")
Response.write("<font color='Red'>" & objMailbox.Name & "</font><br>")
Dim homeMDB
homeMDB = "CN=Mailbox Store (ITEXCHANGE),CN=First Storage Group,
CN=InformationStore," &_
CN=ITEXCHANGE,CN=Servers,CN=First Administrative Group, CN=Administrative
Groups,"&_
CN=Corel IT,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=itdev,DC=lab"
' The following sentence has error saying "Invalid Argument"
ObjMailbox.CreateMailbox "LDAP://itads.itdev.lab/" & homeMDB
userObj.SetInfo
%>
Jacky Zhang
Corel Cororation
728-0826 EXT: 1589
Message #2 by "Siegfried Weber" <sweber@c...> on Tue, 30 Oct 2001 10:47:01 +0100
|
|
I believe your HomeMDB value is slightly wrong. If your AD domain is
"itads.itdev.lab", shouldn't it be:
"CN=Mailbox Store (ITEXCHANGE), " & _
"CN=First Storage Group, " & _
"CN=InformationStore, " & _
"CN=ITEXCHANGE, " & _
"CN=Servers, " & _
"CN=First Administrative Group, " & _
"CN=Administrative Groups, " & _
"CN=Corel IT, " & _
"CN=Microsoft Exchange, " & _
"CN=Services, " & _
"CN=Configuration, " & _
"DC=itads, " & _
"DC=itdev, " & _
"DC=lab"
Your best bet is to install the Windows 2000 Support tools and use
ADSIEdit to find the correct LDAP path.
<Siegfried />
|
|
 |