包括NT用户的建立,EXCHANGE邮箱的建立,两者的结合,权限的设置
本代码在nt4.0+sp6+exchange5.5+adsi2.5下运行通过
建立以后的用户可以直接收发信件,是一个简化版本的WEB MAIL ACCESS
adsi_exchange.asp
-----------------------------------------------------------------------
<%
Set sid = CreateObject("ADsSID")
Set sec = CreateObject("ADsSecurity")
Set ace = CreateObject("AccessControlEntry")
'----------------------------------------------------------------------------
'--- 如果没有安装ADSI2.5的安全库要手工定义以下参数
'-----------------------------------------------------------------------------
Const ADS_SID_HEXSTRING = 1
Const ADS_SID_WINNT_PATH = 5
Const ADS_RIGHT_EXCH_MODIFY_USER_ATT = &H2
Const ADS_RIGHT_EXCH_MAIL_SEND_AS = &H8
Const ADS_RIGHT_EXCH_MAIL_RECEIVE_AS = &H10
'-------------------------------------------------------
'-----创建邮箱步骤----------------------
'--------------------------------------------------------
'---- 基本信息
server1 = "114DOMAINSERVER"
Org = "114ONLINE"
Site = "EXCHANGE"
domain = "EXCHANGE"
userName = "liuoo"
password = "43444"
'--- 邮箱信息 -----
strDisplayName = "rtrtrt"
strFirstName = "gfgf"
strLastName = "fgfgfg"
strAlias = userName
strMTA = "cn=Microsoft MTA,cn=" & server1 & ",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org
strMDB = "cn=Microsoft Private MDB,cn=" & server1 & ",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org
strSMTPAddr = "ewwe@114online.com"
'------ 建立一个nt用户
Set dom = GetObject("WinNT://" & domain)
Set usr = dom.Create("user", userName)
'On Error Resume Next
usr.SetInfo
'If Err.Number <> 0 Then
' Response.Write "111"
' 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
'--------------------------------------------------------
' 与nt用户联系
'---------------------------------------------------------
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"
%>
------------------------------------------------------------------------
请注意权限的设置
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |