[Date Prev][Date Next] [Chronological] [Thread] [Top]

VB.NET and OpenLDAP



I am trying to access OpenLDAP using the .NET System.DirectoryServices
namespace.  I can access all the "standard" properties that MSoft implements
in AD, such as sn, mail, givenname, etc.  But when I try to access a
property not in AD, such as displayname, I get an object type of
System.NotImplementedException:

displayname is type:System.NotImplementedException

I cannot seem to find any way to convert this System.NotImplementedException
object type to any type of data where I can get the displayname to a string.

Has anyone else been successful using custom LDAP fields with
System.DirectoryServices?

Thanks,
Fox

--- Beginning of code ---

Dim objEntry As DirectoryEntry
Dim objSearcher As DirectorySearcher
Dim objSearchResult As SearchResult
Dim objDisplayName As Object
Dim strDisplayName As String

Try

objEntry = New DirectoryEntry("LDAP://leconte.mckee.com/dc=mckee,dc=com";,
"cn=Manager,dc=mckee,dc=com", "mypassword", AuthenticationTypes.ServerBind)

' Set up to search for UserMan on the Users node
objSearcher = New DirectorySearcher(objEntry, "(uid=" & strLogonName & ")")

' Find the user
objSearchResult = objSearcher.FindOne()

' Check if the user was found

If Not objSearchResult Is Nothing Then
' Display path for user

   Dim myResultPropColl As ResultPropertyCollection
   Dim theValue As String
   myResultPropColl = objSearchResult.Properties
   Dim myKey As String
   For Each myKey In myResultPropColl.PropertyNames
      Dim tab1 As String = " "
      Dim myCollection As Object
      For Each myCollection In myResultPropColl(myKey)
         If myCollection.GetType().ToString() = "System.String" Then
            theValue = myCollection.ToString()
            MWin.Text = MWin.Text & vbCrLf & "string for " + myKey + tab1 +
theValue & vbCrLf
         Else
            MWin.Text = MWin.Text & vbCrLf & myKey & " is type:" &
myCollection.GetType().ToString() & vbCrLf
         End If
      Next myCollection
   Next myKey
Else

End If

Catch

MWin.Text = MWin.Text & Err.Number & "-" & Err.Description

End Try

End Function