ASP Create a piece of code for Exchange users

zhaozj2021-02-16  55

Recently, I must have you must create an Exchange 2000 user with ASP, but the previous similar articles are about Exchange 5.5, and it is clear that it is not backward compatible, so it has been wandering in the MSDN website for a long time, and finally found a little information. After adapting, finally can use ASP.

The environment of this ASP execution is in W2K IIS5, and there must be sufficient permissions.

If there is something wrong, please correct your finger.

<% @ Language = VBScript%>

<% Dim objUserDim objContainerDim objMailboxDim recipname, recipDim ServerName, DomainName, emailname, FirstName, LastName, passwordServerName = "skyword.program.org" DomainName = "DC = program, DC = org" emailname = "test" password = "1234" recip = "Cn =" & emailnamelastname = "sky" firstname = "word" set objcontainer = getObject ("ldap: //" & servername "/ou=China.org," & domainname)

Set objUser = objContainer.Create ( "User", recip) objUser.Put "samAccountName", emailnameobjUser.Put "sn", LastNameobjUser.Put "givenName", FirstNameobjUser.Put "DisplayName", "test@hina.org" objUser. Put "UserPrincipalName", emailname & "@ china.org" objuser.setinfoobjuser.setpassword passwordobjuser.accountdisabled = falseobjuser.setInfo

Set objmailbox = objuser

objMailbox.CreateMailbox "LDAP: //skyword.program.org/CN=Mailbox Store (SKYWORD), CN = First Storage Group, CN = InformationStore, CN = SKYWORD, CN = Servers, CN = First Administrative Group, CN = Administrative Groups , CN = ecitye, CN = Microsoft Exchange, CN = Services, CN = Configuration, DC = program, DC = org "objUser.SetInfoSet objContainer = NothingSet objUser = NothingSet objMailbox = Nothingif err <> 0 thenResponse.Write" failed "elseResponse. Write "Success !!!" End IF%> Note: If you use this code, please pay attention to the LDAP on your machine. Articles about ADSI and LDAP are introduced in the essence, plus I don't understand, I don't introduce it. ;)

转载请注明原文地址:https://www.9cbs.com/read-17913.html

New Post(0)