Directory Services |
A server that provides the Novell NetWare Directory Services can be accessed with ADSI by binding to an object with an NDS ADsPath. The NDS provider supports any of the ADSI objects of NDS.
Before ADSI can be used with NDS, the Novell NetWare gateway and client services must be installed and the Novell NDS Server must be accessible from the network.
Note The Adsnds.dll and Activeds.dll files must be installed on the client system in order for that client to be able to have access to the NDS provider.
To Install Novell NetWare Client Services on Windows NT 4.0
Note The Gateway and Client Service for NetWare must be installed before ADSI 2.5 is installed.
To Install Novell NetWare Client Services on Windows 2000
To Install Novell NetWare Client Services on Windows XP and Windows Server 2003
The following code example shows how to enumerate the objects contained by an NDS server.
Sub EnumNDSObjects(serverName As String, userName As String, password As String) ' Bind to the provider. Set dso = GetObject("NDS:") ' For the NDS provider, the flag is set to 0 because secure authentication ' is provided by default. Set cont = dso.OpenDSObject("NDS://" + serverName, userName, password, 0) ' Enumerate the server objects. For Each obj In cont Debug.Print obj.Name & " (" & obj.Class & ")" Next End Sub
To retrieve and modify a user object's attribute, bind to the NDS object and use the IADs.Get and IADs.Put methods. The following code example shows how to change the last name of a user object using the NDS provider.
Sub SetUserSurname(ADsPath As String, newSurname As String, userName As String, password As String) ' Bind to the provider. Set dso = GetObject("NDS:") ' Bind to the user object. Set usr = dso.OpenDSObject(ADsPath, userName, password, 0) ' Display the current surname. Debug.Print usr.Get("Surname") ' Modify the surname in the local cache. usr.Put "Surname", newSurname ' Commit the change to the server. usr.SetInfo End Sub
The following code example shows how to create a new user object using the NDS provider.
Sub CreateUserNDS(containerADsPath As String, newCommonName As String, newSurname As String, userName As String, password As String) ' Bind to the provider. Set dso = GetObject("NDS:") ' Bind to the container. Set cont = dso.OpenDSObject(containerADsPath, userName, password, 0) ' Create the new user. Set usr = cont.Create("user", "CN=" + newCommonName) ' Set the cn attribute. usr.Put "cn", newCommonName ' Set the Surname attribute. usr.Put "Surname", newSurname ' Commit the changes to the server. usr.SetInfo End Sub
The following code example shows how to search an NDS server for an object with a specific attribute value. This example searches for all objects with a Surname attribute that matches a specified value.
Sub SearchNDSForUser(ADsPath As String, surname As String, userName As String, password As String) ' Create the ADO object. Set con = CreateObject("ADODB.Connection") ' Initialize the ADO object. con.Provider = "ADsDSOObject" con.Properties("User ID") = userName con.Properties("Password") = password con.Open "ADSI" ' Create the ADO command object. Set com = CreateObject("ADODB.Command") ' Set the command object's connection to the ADO object. Set com.ActiveConnection = con com.CommandText = "SELECT ADsPath, 'Object Class' FROM '" & ADsPath & "' WHERE Surname=" & surname ' Execute the query. Set rs = com.Execute ' Enumerate the results. While Not (rs.EOF) Debug.Print rs.Fields("ADsPath") rs.MoveNext Wend End Sub