Wrox Home  
Search P2P Archive for: Go

  Return to Index  

exchange_server thread: How do I create an E-mail account on exchange 2000 server using VBScript?


Message #1 by Jacky Zhang <xuejunca@y...> on Wed, 24 Oct 2001 14:41:49 -0400 (EDT)
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 Corporation
728-0826 EXT: 1589


  Return to Index