快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

韦德 bv1946_一段ADSI和EXCHANGE结合的示范代码



在独孤九剑兄的赞助下,完成了这段代码

包括NT用户的建立,EXCHANGE邮箱的建立,两者的结合,权限的设置

本代码在nt4.0+sp6+exchange5.5+adsi2.5下运行经由过程

建立今后的用户可以直接管发信件,是一个简化版本的WEB MAIL ACCESS

adsi_exchange.asp

--------韦德 bv1946---------------------------------------------------------------

0 Then

' Response.Write "111韦德 bv1946"

' Response.Write Err.Description

' Response.End

'End If

usr.SetPassword password

'--- 创建邮箱

ADsPath = "LDAP://" + server1

ADsPath = ADsPath + "/cn=Recipients,OU="

ADsPath = ADsPath + Site

ADsPath = ADsPath + ",O="

ADsPath = ADsPath + Org

Set objCont = GetObject(ADsPath)

'Create a new MailBox

Set mailBox = objCont.Create("organizationalPerson", "cn=" & strAlias)

mailBox.Put "mailPreferenceOption", 0

mailBox.Put "givenName", strFirstName

mailBox.Put "sn", strLastName

mailBox.Put "cn", strDisplayName

mailBox.Put "uid", strAlias

mailBox.Put "Home-MTA", strMTA

mailBox.Put "Home-MDB", strMDB

mailBox.Put "mail", strSMTPAddr

mailBox.Put "MAPI-Recipient", True

mailBox.Put "rfc822Mailbox", strSMTPAddr

'---------------韦德 bv1946-----------韦德 bv1946------------------------------

' 与nt用户联系

'-----------------韦德 bv1946----------------------------------------

sid.SetAs ADS_SID_WINNT_PATH, "WinNT://" & domain & "/" & strAlias & ",user"

sidHex = sid.GetAs(ADS_SID_HEXSTRING)

mailBox.Put "Assoc-NT-Account", sidHex

' 完成设置

mailBox.SetInfo

'-------------------------------------------------

'变动安然设置

'-------------------------------------------------

Set sd = sec.GetSecurityDescriptor(mailBox.ADsPath)

Set dacl = sd.DiscretionaryAcl

ace.Trustee = domain & "\" & strAlias

ace.AccessMask = ADS_RIGHT_EXCH_MODIFY_USER_ATT Or ADS_RIGHT_EXCH_MAIL_SEND_AS Or ADS_RIGHT_EXCH_MAIL_RECEIVE_AS

ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED

dacl.AddAce ace

sd.DiscretionaryAcl = dacl

sec.SetSecurityDescriptor sd

response.write "successful"

%>

------------------------------------------------------------------------

请留意权限的设置

您可能还会对下面的文章感兴趣: