Platform SDK: Active Directory, ADSI, and Directory Services

NWCOMPAT Example Code

If you have not logged on to the NetWare Server, you must use the net use command to log on before using any ADSI NWCOMPAT services. For example,

net use \\nwserver /U:mydom\jsmith

This is required because IADsOpenObject::OpenDSObject is not supported in the current release of the NWCOMPAT provider.

This example enumerates the various ADSI objects of an NWCOMPAT server.

servername = "ntmarst2"
adsPathName = "NWCOMPAT://" & serverName
Set cont = GetObject(adsPathName)
 
'Enumerate the server's objects.
For Each obj In cont
    Debug.Print obj.Name & " (" & obj.Class & ")"
Next

This example creates a new user with a username of "alicew".

adsPath = "NWCOMPAT://" & serverName
Set cont = GetObject(adsPath)
Set usr = cont.Create("user", "alicew")
usr.SetInfo

This example changes a particular user's full name to "Alice I. Wonderland".

objPath = "alicew,user"
adsPath = "NWCOMPAT://" & serverName & "/" & objPath
Set usr = GetObject(adsPath)
usr.FullName = "Alice I. Wonderland"
usr.SetInfo

Searching is not supported in NWCOMPAT. You can, however, use the IADsContainer::put_Filter method to limit the type of object classes to be included in the enumeration.

adsPath = "NWCOMPAT://" & serverName
Set con = GetObject(adsPath)
con.Filter = Array("user", "group") 'Show user and group
 
For Each acct In con
    Debug.Print acct.Name & " (" & acct.Class & ")"
Next