最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP创建EXCHANGE用户的一段代码
时间:2022-06-30 11:39:02 编辑:袖梨 来源:一聚教程网
近日逼不得已必须用ASP创建EXCHANGE 2000用户,但以前的相似文章都是关于EXCHANGE 5。5的,而且明确说明不向后兼容,因此在MSDN网站游荡了很久,终于找到一点资料,经过改编,终于能用于ASP。
此段ASP的执行的环境在W2K+IIS5,并且必须要有足够的权限。
如有不当之处,请高手指正。
<%@ Language=VBScript %>
>
<%
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", "[email protected]"
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
%>
注:如果使用此代码,请注意你的机器上的LDAP不同。有关ADSI和LDAP的文章在精华有介绍,加上我也不太懂就不介绍了。
;)
此段ASP的执行的环境在W2K+IIS5,并且必须要有足够的权限。
如有不当之处,请高手指正。
<%@ Language=VBScript %>
>
<%
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", "[email protected]"
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
%>
注:如果使用此代码,请注意你的机器上的LDAP不同。有关ADSI和LDAP的文章在精华有介绍,加上我也不太懂就不介绍了。
;)
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22