This is the top level of the NWDir UCX Component. This Directory component can enumerate all objects under a context in a given tree. A sub object of this component represents an NDS object. It does the following:
Provides methods for authentication to NDS
Enumerates layouts and fields of the NDS Schema.
Identifes the entries, layouts and field types in NDS; searches for and filters entries under a given context in a given tree.
For Web-based scripts, automatically detects the NDS user connected to the Enterprise Server.
Provides/sets the full name of the context.
object.FullName
String.
Read-write.
By default refers to the tree and context for the server on which the script is running. The FullName syntax is
"NDS:\\ACME-Tree\TopContext\SubContext"
This example lists all the objects under the given context.
On Error Resume Next
Set nwdir = CreateObject("UCX:NWDIR")
’Enter the NDS context of the server
nwdir.FullName = "NDS\\ACMECorporation\Sales\New York"
’Enter your login name and password
If (NOT nwdir.login ("Test User", "Test Password")) Then
Print "Login Failure"
Else
Print "Login Success"
Print "Current FullName: " &nwdir.FullName
Print "Current ShortName: " &nwdir.ShortName
Print "Current User: " &nwdir.LoginName
Print "Current Entry Object: " &nwdir.Entry.ShortName
Print "objects under current context are"
For each entry in nwdir.Entries
Print entry.ShortName
Next
Endif
’Logout
nwdir.Logout()
Gives the short name of the current context.
object.ShortName
String.
Read-only.
The short name is commonly used where you want to see only the name of the object relative to its parent, instead of its full name.
This example gives the short name of the current context.
Set dirObj = CreateObject("UCX:NWDIR")
’Enter your username and password
dirObj.Login("user", "password")
Print "Current ShortName: " &dirobj.ShortName
Provides/sets the preferred Novell eDirectory server to which the component establishes the connection.
object.PrefServer
Read-Write.
String.
If this value is not set, the component connects to the nearest server in the tree. By default, the value is set to "".
This example uses the preferred server to connect to eDirectory and lists all the objects.
Sub Test_PrefServer
set nwdir=createobject("UCX:NWDIR")
nwdir.fullname="NDS:\\treename\context"
nwdir.prefserver="164.99.150.91"
For Each entry In nwdir.entries
Print entry.shortname
Next
End Sub
text goes here
object.LoginName
Read-only.
String.
By default the value is NULL string.
This example returns the name of the user logged into NDS.
Set dirObj = CreateObject ("UCX:NWDIR")
’Enter the NDS context of the server
dirObj.FullName = "NDS\\ACMECorporation\Sales\New York"
’Enter the username and password
dirObj.Login("user", "password")
Print "Current User: " &dirObj.LoginName
Returns the collection of entries at the context specified by FullName property.
object.Entries
NWEntries.
Read-only.
This example lists all the objects under the given context.
Set nwdir = CreateObject("UCX:NWDIR")
’enter the nds context of the server
nwdir.FullName = "NDS\\ACMECorporation\Sales\New York"
’enter the username and password
If (NOT nwdir.Login("Test User", "Test Password")) Then
Print "Login Failure"
Else
Print "Login Success"
Print "Current FullName: " &nwdir.FullName
Print "Current ShortName: " &nwdir.ShortName
Print "Current User: " &nwdir.LoginName
Print "Current Entry Object: " &nwdir.Entry.ShortName
’Print the name of all the objects under this context
’Print objects under current context are: "
For each entry in nwdir.Entries
Print entry.ShortName
Next
Endif
’Logout
nwdir.Logout()
Returns the entry object representing the FullName.
object.Entry
NWEntry.
Read-only.
This property is typically used to get and set field values on the entry at the root of the subtree indicated by the FullName property of the NWDir Object.This property can also be used as a convenience to point to an entry in the tree.
This example lists all the objects under the given context.
Set nwdir = CreateObject("UCX:NWDIR")
’enter the NDS context of the server
nwdir.FullName = "NDS:\\ACMECorporation\Sales\New York"
’enter the username and password
If (NOT nwdir.Login ("Test User", "Test Password")) Then
Print "Login Failure"
Else
Print "Login Success"
Print "Current FullName: " &nwdir.FullName
Print "Current ShortName: " &nwdir.ShortName
Print "Current User: " &nwdir.LoginName
Print "Current Entry Object: " &nwdir.Entry.ShortName
’print the name of all the objects under this context
For each entry in nwdir.Entries
Print entry.ShortName
Next
Endif
’Logout
nwdir.Logout()
Returns the collection of layouts of NDS.
object.Layouts
NWLayoutDescriptions.
Read-only.
This example lists all the NDS layouts.
Set dirObj = CreateObject("UCX:NWDIR")
’enter the username and password
dirObj.Login("user","password")
For each layout in nwdir.Layouts
Print layout.Name
Next
Returns a collection of all the field types (NDS Syntax) of the specified NDS tree.
object.FieldTypes
NWFieldTypes.
Read-only.
This example lists the details of each NDS field type.
Set dirObj = CreateObject("UCX:NWDIR")
’enter the username and password
dirObj.Login("user", "password")
For each FieldType in dirobj.FieldTypes
Print FieldType.Name
Print FieldType.SyntaxName
Print FieldType.Type
Print FieldType.Removable
Print FieldType.SingleValued
Print FieldType.SyntaxType
Next
Returns filter object.
object.Filter
NWFilter.
Read-only.
This property returns an empty search filter object. The search conditions have to be added using the properties and methods of NWFilter.After that, this object has to be passed as a parameter to the search method.
See Also Section A.13, Filter/Search Scope Constants and Section A.23, Operator Constants.
This example sets the filter for a search on an NDS object.
Set dirObj = CreateObject("UCX:NWDIR")
’enter the username and password
dirObj.Login("user","password")
Set Filter1 = dirobj.Filter
Filter1.addexpression FTOK_APPROX, "CN", "User3"
Filter1.addexpression FTOK_END
Print "Filter Expression" & Filter1.Value
Set Entries = dirobj.Search(Filter1)
For each Entry in dirobj.Entries
Print Entry.FullName
Next
Logs in to the specified User account in NDS.
object.Login(
UserName As String,
[Password As String])
The login name.
The password for the specified username.
Boolean.
Returns TRUE if login is successful, otherwise returns FALSE and throws exception.
If NWDir component is instantiated inside a Web script or a NSP page, then the component detects the user and performs automatic authentication.
In case the account has expired and the user has grace logins then this method logs into NDS using grace logins and returns TRUE and also sets the Err.Number (-223).
This example gives the default tree and context, performs a login and logs the user out of NDS.
Set dirObj = CreateObject("UCX:NWDIR")
’Enter the NDS context of the server
dirObj.FullName = "NDS:\\Acmecorporation\sales\Newyork"
Print "Current FullName: "&dirObj.FullName
’Log in to the server
Status = dirObj.Login("Username","password")
Print "The Login status is" &Status
’Logout
dirObj.Logout()
Logs out from NDS.
object.Logout()
None.
Boolean. Returns TRUE, if successful else returns FALSE.
This example gives the default tree and context, performs a login and logs the user out of NDS.
Set dirObj = CreateObject("UCX:NWDIR")
’Enter the NDS context of the server
dirObj.FullName = "NDS:\\Acmecorporation\sales\Newyork"
Print "Current FullName: "&dirObj.FullName
Status = dirObj.Login("Username","password")
Print "The Login status is" &Status
dirObj.Logout()
Searches the directory services using the search filter.
object.Search(
Filter As NWFilter)
The filter set for the search.
NWEntries.
Return value is a collection of NWEntry objects. See also Section A.13, Filter/Search Scope Constants and Section A.23, Operator Constants.
The following example illustrates how to search NDS using the Search filter.
’List all the users starting with the word User3
Set nwdir = CreateObject("UCX:NWDIR")
nwdir.Login ("User", "Password")
Set Filter1 = nwdir.Filter
’Search entire subtree and dereference the alias objects
Filter1.Scope = SEARCH_SUBTREE
Filter1.DerefAlias = FALSE
Filter1.AddExpression FTOK_APPROX, "CN", "User3"
Filter1.AddExpression FTOK_END
Print "Filter Expression " & Filter1.Value
Print "Default Search Context: " &Filter1.SearchContext
Set Entries = nwdir.Search(Filter1)
For each entry in Entries
Print Entry.FullName
Next
Returns an entry object corresponding to the given full name.
object.FindEntry(
FullName As String)
Full name of the Object to be searched.
NWEntry.
If there is no entry corresponding to the given full name, then returns NULL and throws an exception.
This example creates a new entry, tests for that Entry Object and deletes it.
Set nwdir=CreateObject("UCX:NWDIR")
’Enter the username and the password
nwdir.Login ("username", "password")
Set entries = nwdir.Entries
Print "Total number of entries: "&Entries.Count
Entries.Reset()
while Entries.HasMoreElements()
Set Entry = Entries.Next()
Print Entry.ShortName
Wend
’Create a new User object
Set newEntry=Entries.Add("TestUser","User")
’Set the mandatory fields and create the entry
newEntry.SetFieldValue "Surname", "Test Surname"
newEntry.Update()
’Confirm the creation of test user
Entries.Reset()
Set TestUser=Entries.Element ("TestUser")
Print " The new user is"&TestUser.FullName
’Finds the entry and displays the related information
’Enter the fullname of the entry
Set Entry=Nwdir.FindEntry("Nds:\\Acmecorporation\Testuser")
’Get the partition in which this entry reside
Set partition = Entry.GetPartitionRoot()
Print " The partition is" &partition.Shortname
’Set the objects's password
Entry.SetPassword ("password")
’Verify the new password
If (Entry.VerifyPassword("password")) Then
Print "Password Verification Success"
Else
Print "Password Verification Failed"
End If
’Delete the test user
Status = Entries.RemoveElement("TestUser")
Print "The deletion status is" &Status
Returns the summary of the subject's rights with respect to the object, ObjectName or an attribute of an object.
object.GetRights(
SubjectName As String,
ObjectName As String,
AttrName As String)
Name of the Subject.
Name of the Object.
The attribute name.
String.
The return value is in the form, [ff..]. The return string contains characters where each character represents a particular right. These characters appear in the order mentioned below. If the object doesn't have a particular right, then a blank will appear in that position.
Following are the possible values and their meanings:
If attrname passed to the method is "[Entry Rights]", then return values are as follows:
B-DS_ENTRY_BROWSE A-DS_ENTRY_ADD D-DS_ENTRY_DELETE R-DS_ENTRY_RENAME S-DS_ENTRY_SUPERVISOR
Example: [BA RS]
If attrname passed to the method is "[SMS Rights]" then return values are these:
S-DS_SMS_SCAN B-DS_SMS_BACKUP R-DS_SMS_RESTORE C-DS_SMS_RENAME D-DS_SMS_DELETE A-DS_SMS_ADMIN
Example: [S R DA]
For other attributes, the following values are returned:
C-DS_ATTR_COMPARE R-DS_ATTR_READ W-DS_TTR_WRITE A-DS_ATTR_SELF S-DS_ATTTR_SUPERVISOR
Example: [CR AS]
This example shows how to get the rights User on the Testuser.
Set nwdir=CreateObject("UCX:NWDIR")
’enter the username and password
nwdir.Login ("User","password")
’Get the rights of User on test user
’Enter the Full name of the User and the test user
rights=nwdir.GetRights ("NDS:\\ACMEcorporation\Sales\User",
"NDS:\\ACMEcorporation\Sales\TestUser","[Entry Rights]")
Print "User's right on TestUser: "&rights
Adds the SecFrom object to the security equivalence list of SecTo.
object.AddSecurity(
SecTo As String,
SecFrom As String)
The destination object whose security equivalence list is added to.
The source object.
Boolean.
This example shows how to add TestUser1 into the security equivalence list of TestUser.
Set nwdir=CreateObject("UCX:NWDIR")
’Enter the username and password
nwdir.Login ("User", "password")
’Adds test user1 to security equivalence of test user
’Enter the full name of the source and the destination entries
If(nwdir.AddSecurity("NDS:\\Acmecorporation\Sales\TestUser1"
"NDS:\\Acmecorporation\Sales\TestUser")) Then
Print "TestUser1 has the security equivalence to TestUser"
Else
Print "Failed to add TestUser1 into the security
equivalence list of TestUser"
End If
Removes the security equivalence from SecTo object.
object.RemoveSecurity(
SecTo As String, SecFrom As String)
The destination object whose security equivalence list is added to.
The source object.
Boolean.
This example shows how to remove TestUser1 from the security equivalence list of Testuser.
Set nwdir=CreateObject("UCX:NWDIR")
’Enter the user name and password
nwdir.Login ("User", "password")
’Removes test user1 from security equivalence of test user
’Enter the full name of the source and the destination entries
If (nwdir.RemoveSecurity
("NDS:\\Acmecorporation\Sales\TestUser1","NDS:\\Acmecorporat
ion\Sales\\TestUser")) Then
Print "TestUser1 is removed"
Else
Print "Failed to remove TestUser1 from the security
equivalence of TestUser"
End If
Changes the object's position in the tree.
object.MoveEntry(
OldFullName As String,
NewFullName As String)
The old full name of the object.
The new full name of the object.
Boolean.
This example shows how to move an entry, TestUser1 to another context.
Set nwdir=CreateObject("UCX:NWDIR")
’Enter the username and password
nwdir.Login ("User","password")
’Enter the full name of source and the destination
res=nwdir.MoveEntry ("NDS:\\ACMECorporation\Sales\TestUser1", "NDS:\\ACMECorporation\Sales\NewYork\TestUser1")
If (res) Then
Print "Testuser1 is successfully moved"
Else
Print "Failed to move TestUser1"
End If