Microsoft KB Archive/192781: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 66: Line 66:


   'The path to the ou=Members container
   'The path to the ou=Members container
   strLdapPath = "LDAP://localhost:5292/o=Microsoft/ou=Members"
   strLdapPath = "LDAP://localhost:5292/o=Microsoft/ou=Members"


   'Instantiate the GUID Generator that comes with Site Server
   'Instantiate the GUID Generator that comes with Site Server
   'and store the GUID for use later on.
   'and store the GUID for use later on.
   Set oGuidGen = CreateObject("Membership.GuidGen.1")
   Set oGuidGen = CreateObject("Membership.GuidGen.1")


   strGuid = oGuidGen.GenerateGuid
   strGuid = oGuidGen.GenerateGuid
Line 78: Line 78:
   returns
   returns
   'an interface pointer
   'an interface pointer
   Set oADsNewUser = oADsContainer.Create("member", "cn=JohnDoe")
   Set oADsNewUser = oADsContainer.Create("member", "cn=JohnDoe")
   oADsNewUser.Put "givenName", "John"
   oADsNewUser.Put "givenName", "John"
   oADsNewUser.Put "sn", "Doe"
   oADsNewUser.Put "sn", "Doe"
   oADsNewUser.Put "userPassword", "password"
   oADsNewUser.Put "userPassword", "password"
   oADsNewUser.Put "GUID", CStr(strGuid)
   oADsNewUser.Put "GUID", CStr(strGuid)
   oADsNewUser.SetInfo
   oADsNewUser.SetInfo
   'Destroy the objects
   'Destroy the objects
Line 95: Line 95:
== REFERENCES ==
== REFERENCES ==


"Active Directory Service Interfaces Version 2.0" located in the Microsoft Developer Network Library / SDK Documentation / Platform SDK / Networking and Distributed Services
"Active Directory Service Interfaces Version 2.0" located in the Microsoft Developer Network Library / SDK Documentation / Platform SDK / Networking and Distributed Services


</div>
</div>

Latest revision as of 12:43, 21 July 2020

Knowledge Base


How To How to Programmatically Create Members in Site Server 3.0

Article ID: 192781

Article Last Modified on 2/18/2005



APPLIES TO

  • Microsoft Site Server 3.0 Standard Edition



This article was previously published under Q192781

SUMMARY

This article describes how to programmatically create members in Site Server 3.0 Membership Directory using Active Directory Service Interfaces (ADSI) 2.0 and VBScript.

MORE INFORMATION

When you create a new Member object, the following three properties must be set:

  • objectClass
  • cn (Common Name)
  • GUID

The first two, objectClass and cn, are set when the Create() method is called. The third, GUID, must explicitly be set. If these properties are not set properly, the call to SetInfo() will fail and the new Member object will not be created.

The following code demonstrates adding a member programmatically:

Dim oADsContainer
   Dim oADsNewUser
   Dim oGuidGen
   Dim strGuid
   Dim strLdapPath

   'The path to the ou=Members container
   strLdapPath = "LDAP://localhost:5292/o=Microsoft/ou=Members"

   'Instantiate the GUID Generator that comes with Site Server
   'and store the GUID for use later on.
   Set oGuidGen = CreateObject("Membership.GuidGen.1")

   strGuid = oGuidGen.GenerateGuid
   'Bind to the container in which the Member will be created
   Set oADsContainer = GetObject(strLdapPath)
   'Create the new user object, note that the Create() method
   returns
   'an interface pointer
   Set oADsNewUser = oADsContainer.Create("member", "cn=JohnDoe")
   oADsNewUser.Put "givenName", "John"
   oADsNewUser.Put "sn", "Doe"
   oADsNewUser.Put "userPassword", "password"
   oADsNewUser.Put "GUID", CStr(strGuid)
   oADsNewUser.SetInfo
   'Destroy the objects
   Set oGuidGen = Nothing
   Set oADsNewUser = Nothing
   Set oADsContainer = Nothing
                

REFERENCES

"Active Directory Service Interfaces Version 2.0" located in the Microsoft Developer Network Library / SDK Documentation / Platform SDK / Networking and Distributed Services


Additional query words: kbDSupport

Keywords: kbhowto KB192781