Using ADSI with NDS Providers
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.
Windows Vista: NDS providers are not supported.
Installing the Novell NetWare Client Services
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
- Click the Start button, go to Settings and click Dial-up Connection.
- Click Local Network.
- Click Client for Microsoft Network.
- Click Install.
- Select the Client icon, then click Add.
- Select Gateway (and Client) Services for NetWare and click OK.
- Restart the computer when prompted.
To Install Novell NetWare Client Services on Windows XP and Windows Server 2003
- Click the Start button, select Control Panel and open Network Connections.
- Right-click Local Area Connection and select Properties.
- Click Install.
- Select the Client icon and then click Add.
- Select Client Service for NetWare and click OK.
- Restart the computer when prompted.
Example Code
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
Send comments about this topic to Microsoft
Build date: 10/26/2012