明輝手游網(wǎng)中心:是一個免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

ASP創(chuàng)建EXCHANGE用戶的一段代碼

[摘要]近日逼不得已必須用ASP創(chuàng)建EXCHANGE 2000用戶,但以前的相似文章都是關(guān)于EXCHANGE 5。5的,而且明確說明不向后兼容,因此在MSDN網(wǎng)站游蕩了很久,終于找到一點(diǎn)資料,經(jīng)過改編,終于能用于ASP。此段ASP的執(zhí)行的環(huán)境在W2K+IIS5,并且必須要有足夠的權(quán)限。如有不當(dāng)之處,請高手...
近日逼不得已必須用ASP創(chuàng)建EXCHANGE 2000用戶,但以前的相似文章都是關(guān)于EXCHANGE 5。5的,而且明確說明不向后兼容,因此在MSDN網(wǎng)站游蕩了很久,終于找到一點(diǎn)資料,經(jīng)過改編,終于能用于ASP。

此段ASP的執(zhí)行的環(huán)境在W2K+IIS5,并且必須要有足夠的權(quán)限。

如有不當(dāng)之處,請高手指正。


<%@ 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 "失敗"
else
Response.Write "成功!!!"
end if
%>
</BODY>
</HTML>


注:如果使用此代碼,請注意你的機(jī)器上的LDAP不同。有關(guān)ADSI和LDAP的文章在精華有介紹,加上我也不太懂就不介紹了。 ;)