当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP创建EXCHANGE用户的一段代码

ASP
看人家用使用InstallShield制作ASP安装程序(5)
看人家用使用InstallShield制作ASP安装程序(4)
看人家用使用InstallShield制作ASP安装程序(3)
看人家用使用InstallShield制作ASP安装程序(2)
看人家用使用InstallShield制作ASP安装程序(1)
取得浏览者的离开时间
base64编码、解码函数
动态显示图片的函数(显示广告条)
发送带附件的HTML格式邮件例程可以带附件
一种在父窗口中得知window.open()出的子窗口关闭事件的方法
一个老个写的无组件上传
避免asp的SQL的执行效率低
树型结构在ASP中的简单解决
无需数据库循环的无级分类代码
检查字符串strSource是否为big或big5码
有关重复记录的删除(SQL SERVER)
WINDOWS2000服务器账号登陆身份验证
使用VC++6.0制作ASP服务器控件简介
利用sql的存储过程实现dos命令的asp程序
WSH 直接将查询数据结果生成 EXCEL 表

ASP创建EXCHANGE用户的一段代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 92 ::
收藏到网摘: n/a

  近日逼不得已必须用ASP创建EXCHANGE 2000用户,但以前的相似文章都是关于EXCHANGE 5。5的,而且明确说明不向后兼容,因此在MSDN网站游荡了很久,终于找到一点资料,经过改编,终于能用于ASP。

此段ASP的执行的环境在W2K+IIS5,并且必须要有足够的权限。

如有不当之处,请高手指正。


<%@ 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", "[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
%>
</BODY>
</HTML>


注:如果使用此代码,请注意你的机器上的LDAP不同。有关ADSI和LDAP的文章在精华有介绍,加上我也不太懂就不介绍了。 ;)