日期:2011-09-12  浏览次数:21150 次


概要
本文讨论如何使用 Active Directory Service Interfaces (ADSI) 2.0 和 VBScript 通过编程将成员添加至 Site Server 3.0 Membership Directory 的某个特定组中。


更多信息
按照下列步骤将某个成员添加至 Site Server 3.0 的一个组中:


绑定要添加用户的组。


根据要添加至组(成员必须存在)的用户的公用名称 (CN) 创建新 MemberOf 对象。


将 MemberObject 属性设置为要添加用户的辨别名称 (DN)。


下列代码演示了该过程:
Dim adsMemberOf
Dim adsGroup
Dim strLdapSrv
Dim strMemberPath, strUserCn, strUserDn, _
strGroupDn, strAdmin, strAdminPwd

strLdapSrv = "LDAP://localhost:5292"
strMemberPath = ",ou=Members,o=Microsoft"
strUserCn = "cn=JohnDoe"
strUserDn = strUserCn + strMemberPath
strGroupDn = strLdapSrv +
"/o=Microsoft/ou=Groups/cn=Public"
strAdmin = "cn=Administrator,ou=Members,o=Microsoft"
strAdminPwd = "password"

'Bind to the specific group using Administrator credentials
Set adsGroup = GetObject("LDAP:")
Set adsGroup = adsGroup.OpenDSObject(strGroupDn, strAdmin, _
strAdminPwd, CLng(0))

'Create the new 'memberOf' object that will be stored in the
group
Set adsMemberOf = adsGroup.Create("memberof", strUserCn)
'Add the path to the user and store it in the 'memberObject'
property
adsMemberOf.Put "memberobject", CStr(strUserDn)

'Flush the property cache and update the directory
adsMemberOf.SetInfo

'Destroy the objects
Set adsMemberOf = Nothing
Set adsGroup = Nothing

参考
Active Directory Service Interfaces version 2.0 位于 Microsoft Developer Network Library/SDK Documentation/Platform SDK/Networking and Distributed Services 上。

关键字:prodsitesrv3
问题类型:
问题类型技术: