Directory Services |
[This documentation is preliminary and subject to change.]
To create an inetOrgPerson object, bind to the object that will contain the object, create an inetOrgPerson object, set its properties, and save the object to the directory store.
The following code example assumes that the schema of the ADAM instance has been extended by Adding ADAM User Classes.
The following VBScript code example uses the GetObject function to bind to an organization object and uses the Create method to create inetOrgPerson objects in that organization.
' Create inetOrgPerson Objects. Option Explicit Dim objADAM ' Binding object. Dim objUser ' inetOrgPerson. Dim strPath ' Binding path. Dim strUser ' Selected user. Dim strUsers ' Array users. ' Construct ADAMsPath binding string. ' Change "localhost" to appropriate server. ' Change "389" to port for appropriate instance. ' Change "O=Fabrikam,C=US" to appropriate object. strPath = "LDAP://localhost:389/O=Fabrikam,C=US" WScript.Echo "Bind to: " & strPath On Error Resume Next ' Bind to object. Set objADAM = GetObject(strPath) ' Output error if the bind operation fails. If Err.Number <> vbEmpty Then WScript.Echo "Error: Bind failed." WScript.Quit Else WScript.Echo "Success: Bind succeeded." End If ' Specify Users. strUsers = Array("inetuser1", "inetuser2", "inetuser3") ' Loop through and create users. For Each strUser in strUsers ' Create User. WScript.Echo "Create: " & strUser Set objUser = objADAM.Create("inetOrgPerson", "CN=" & strUser) objUser.SetInfo ' Output success or error. If Err.Number <> vbEmpty Then WScript.Echo "Error: Create failed with error #" _ & Hex(Err.Number) & ", " _ & Err.Description & "." Else WScript.Echo "Success: User created." WScript.Echo " Name: " & objUser.Name End If Set objUser = Nothing Next