LDAP Schema

  • Thread starter Thread starter Kenneth H. Young
  • Start date Start date
K

Kenneth H. Young

I have developed an LDAP client application that I would like to add a treeview to that will display the schema for the People OU. I am testing with the following code to try to figure out but I'm not getting anywhere.:
Sub Main()
Dim myADSPath As String = "LDAP://servername:636/dc=ccs,dc=nrl,dc=navy,dc=mil"

' Creates an Instance of DirectoryEntry.
Dim myDirectoryEntry As New DirectoryEntry(myADSPath)

' Display the 'SchemaClassName'.
Console.WriteLine("Schema class name:" + myDirectoryEntry.Name())
Dim scn = myDirectoryEntry.SchemaClassName
' Gets the SchemaEntry of the ADS object.
Dim mySchemaEntry As DirectoryEntry = myDirectoryEntry.SchemaEntry

Dim myChildDirectoryEntry As DirectoryEntry

For Each myChildDirectoryEntry In myDirectoryEntry.Children
Console.WriteLine(myChildDirectoryEntry.Name)
Next myChildDirectoryEntry

End Sub

I get these Results:

Schema class name:dc=ccs
cn=Directory Administrators
ou=Groups
ou=Special Users
uid=kaskel
uid=ccsldap
ou=Accounts
uid=sborders
ou=People
ou=organization

Now what I would like for results for the People OU is the table field names: i.e.
uid
title
telephoneNumber
sn
site
roomNumber
givenName
cn
mail
etc...
This will aid in mapping the LDAP to the static database file.
Thank you for any assistance!
 
Hi

Is this what you want?
We can use Properties to get the different property.
NOTE: we can not guarantee all the myChildDirectoryEntry has the following
properties, so we use the On Error Resume Next.

Imports System.DirectoryServices
Module Module1
Sub Main()
On Error Resume Next
Dim myADSPath As String =
"LDAP://servername:636/dc=ccs,dc=nrl,dc=navy,dc=mil"
' Creates an Instance of DirectoryEntry.
Dim myDirectoryEntry As New DirectoryEntry(myADSPath)
' Display the 'SchemaClassName'.
Console.WriteLine("Schema class name:" + myDirectoryEntry.Name)
Dim scn = myDirectoryEntry.SchemaClassName
' Gets the SchemaEntry of the ADS object.
Dim mySchemaEntry As DirectoryEntry = myDirectoryEntry.SchemaEntry
Dim myChildDirectoryEntry As DirectoryEntry
For Each myChildDirectoryEntry In myDirectoryEntry.Children
Console.WriteLine(myChildDirectoryEntry.Name)
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("cn").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("uid").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("title").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("telephoneNumber").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("sn").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("site").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("roomNumber").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("givenName").Value.ToString())
Console.WriteLine(" " +
myChildDirectoryEntry.Properties("mail").Value.ToString())
Next myChildDirectoryEntry
End Sub
End Module

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
No that isn't quite what I am looking for, that will return the data
from the LDAP server. I am trying to retrieve the schema or table names not
the contents. From one server to the next the schema or data field names in
the LDAP server can change and I need to programaticaly find there names so
I can map them accordingly. Below are two lists of data field names, one is
from my Windows 2000 AD the second is from the labs Sun ldap server.

Active Directory
st:
sn:
telephoneNumber:
co:
textEncodedORAddress:
title:
userAccountControl:
userParameters:
userPrincipalName:
userSMIMECertificate:
uSNChanged:
uSNCreated:
whenChanged:
whenCreated:
wWWHomePage:
userCertificate:
msExchADCGlobalNames:
autoReplyMessage:
deletedItemFlags:
deliverAndRedirect:
extensionAttribute1:
dLMemDefault:
msExchHideFromAddressLists:
homeMTA:
msExchHomeServerName:
msExchMailboxGuid:
msExchMailboxSecurityDescriptor:
mailNickname:
mAPIRecipient:
mDBUseDefaults:
protocolSettings:
replicatedObjectVersion:
replicationSignature:
securityProtocol:
msExchALObjectVersion:
msExchPoliciesIncluded:
msExchUserAccountControl:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The Sun LDAP server on LAB only has the following fields.
objectClass:
uid:
telephoneNumber:
sn:
site:
roomNumber:
o:
givenName:
employeeType:
departmentNumber:
buildingName:
cn:
initials:
edipi:
physicalDeliveryOfficeName:
citizenshipStatus:
 
Hi

Thanks for your quickly reply!
So far I am researching the issue, and I will update you with new
information ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Kenneth,

You may take a look to see if that works for you.
You will have to bind to the object.
Retrieve the SchemEntry
Declare an IADsClass object from ActiveDs Type Lib
Retireve the nativeobject of the SchemaEntry
Then look at the IADsClass::OptionalProperties and the
IADsClass::MandatoryProperties collections.

Dim myADSPath As String = "LDAP://pathstring"
Dim de As New DirectoryEntry(myADSPath)
Dim sde As DirectoryEntry = de.SchemaEntry
Dim oClass as IADsClass
oClass = sde.NativeObject
Dim b As Object
Console.WriteLine(b)
'
' Optional Attributes
'
for each b in oClass.OptionalProperties
Console.WriteLine(b)
next
'
' Mandatory properties
'
for each b in oClass.MandatoryProperties
Console.WriteLine(b)
next
Console.WriteLine(o.Length)


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top