Directory Services

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.

Installing the Novell NetWare Client Services

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

  1. Click the Start button, go to Settings and click Control Panel.
  2. Double-click Network. The Network dialog box opens.
  3. Click the Service tab.
  4. Select Gateway (and Client) Services for NetWare.
  5. Click OK to install and then restart the computer.
  6. Reinstall the appropriate Windows NT Service Pack, then restart.
  7. Install (or reinstall) ADSI 2.5 or later (http://www.microsoft.com/adsi).

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

  1. Click the Start button, go to Settings and click Dial-up Connection.
  2. Click Local Network.
  3. Click Client for Microsoft Network.
  4. Click Install.
  5. Select the Client icon, then click Add.
  6. Select Gateway (and Client) Services for NetWare and click OK.
  7. Restart the computer when prompted.

To Install Novell NetWare Client Services on Windows XP and Windows Server 2003

  1. Click the Start button, select Control Panel and open Network Connections.
  2. Right-click Local Area Connection and select Properties.
  3. Click Install....
  4. Select the Client icon and then click Add....
  5. Select Client Service for NetWare and click OK.
  6. Restart the computer when prompted.

Example Code [Visual Basic]

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