Programming
Profile
This article discusses how to use Active Directory Service interfaces (ADSI) 2.0 and VBScript to programmatically add members to a specific group in the Site Server 3.0 Membership Directory 。
More information
Follow these steps to add a member to a group in Site Server 3.0:
Bind the group to which you want to add users.
Creates a new MemberOf object based on the common name (CN) of the user to be added to the group (the member must exist).
Set the Memberobject property to the distinguished name (DN) of the user you want to add.
The following code demonstrates this procedure:
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'll be stored in the
Group
Set adsMemberOf = adsgroup.create ("memberof", STRUSERCN)
' Add the path to the ' user and store it ' 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
Reference
Active Directory Service Interfaces version 2 is located in Microsoft Developer network LIBRARY/SDK documentation/platform SDK/NETW Orking and distributed Services.
Keywords: prodsitesrv3
Question type:
Problem type technology: