PC Review


Reply
 
 
Kenneth H. Young
Guest
Posts: n/a
 
      23rd May 2005
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!
 
Reply With Quote
 
 
 
 
Peter Huang [MSFT]
Guest
Posts: n/a
 
      24th May 2005
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.

 
Reply With Quote
 
Kenneth H. Young
Guest
Posts: n/a
 
      24th May 2005
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:

""Peter Huang" [MSFT]" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
Peter Huang [MSFT]
Guest
Posts: n/a
 
      25th May 2005
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.

 
Reply With Quote
 
Peter Huang [MSFT]
Guest
Posts: n/a
 
      26th May 2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I sync a typed dataset schema with database schema easily? John Microsoft Dot NET 1 2nd Jan 2008 11:37 AM
Adding Class in Active Directory Schema through LDAP =?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?= Microsoft Windows 2000 Active Directory 1 26th Mar 2005 06:10 AM
How to extend Active Directory Schema through LDAP APi =?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?= Microsoft Windows 2000 Active Directory 1 23rd Mar 2005 09:25 AM
how to extend Active directory Schema through LDAP API =?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?= Microsoft Windows 2000 Active Directory 1 19th Mar 2005 08:44 AM
LDAP and Schema changes requirement Madhus Microsoft Windows 2000 Active Directory 1 15th Jan 2004 06:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.