ASP create a piece of code for an Exchange user

Source: Internet
Author: User
Tags ldap visual studio skyword
It is imperative that you create Exchange 2000 users with ASP, but previous similar articles are about Exchange 5. 5, and clearly not backward compatibility, so on the MSDN site for a long time, finally found a little information, after adaptation, finally can be used for ASP.

This segment of the ASP's execution environment is W2K+IIS5 and must have sufficient permissions.

If there is any improper place, please correct the master.


<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 7.0" >
</HEAD>
<BODY>
<%
Dim objuser
Dim Objcontainer
Dim Objmailbox

Dim Recipname, Recip
Dim ServerName, domainname, EmailName, FirstName, LastName, password

ServerName = "skyword.program.org"
DomainName = "Dc=program,dc=org"
EmailName = "Test"
Password = "1234"
Recip = "cn=" & EmailName
LastName = "Sky"
FirstName = "Word"

Set Objcontainer = GetObject ("ldap://" & ServerName & "/ou=china.org," & DomainName)

Set objuser = objcontainer.create ("User", Recip)
objUser.Put "sAMAccountName", EmailName
objUser.Put "SN", LastName
objUser.Put "givenname", FirstName
objUser.Put "DisplayName", "test@hina.org"
objUser.Put "userPrincipalName", EmailName & "@China. org"
Objuser.setinfo

Objuser.setpassword Password
objuser.accountdisabled = False
Objuser.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.setinfo

Set Objcontainer = Nothing
Set objuser = Nothing
Set Objmailbox = Nothing

If Err <> 0 Then
Response.Write "Failure"
Else
Response.Write "Success!!!"
End If
%>
</BODY>
</HTML>


Note: If you use this code, please note that the LDAP on your machine is different. The articles about ADSI and LDAP are introduced in the essence, plus I don't quite understand it. ;)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.