VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 网站开发 > ASPnet >
  • asp.net教程之ASP创建EXCHANGE 2000用户的一段代码

此段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", "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> 


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

相关教程