How to extract TNSNames from an LDAP directory

I am trying to query the LDAP directory server to get the tnsnames entry. The following code works for me, but it doesn't smell right. This is because it is wrong, or because the ldap request includes several levels of indirection

   let identifier = LdapDirectoryIdentifier(server, port)
   use connection = new LdapConnection (identifier)
   connection.AuthType <- AuthType.Anonymous
   let request = System.DirectoryServices.Protocols.SearchRequest(defaultAdminContext, "cn=" + sid, SearchScope.OneLevel, "orclnetdescstring")
   let response = connection.SendRequest request :?> SearchResponse

   Seq.init response.Entries.Count (fun i -> response.Entries.[i])
   |> Seq.collect (fun entry ->
       let value = entry.Attributes.["orclnetdescstring"]
       Seq.init value.Count (fun i -> value.[i])
       |> Seq.map (fun v -> Some (v :?> string))
       )

I was hoping for a simple call that basically "queries the directory and returns the result", but to read real values, it seems to me that I need a lot of "things".

+3
source share
1 answer

Once the client is connected to the directory server, the client can make requests and read responses. Queries take the form of LDAP operations, such as binding, searching, adding, modifying, deleting, and others.

, ( LDAP, ) (RFC4513). , - , "" SASL-. , , - , .

:

  • " "
  • " ", ,
  • a " ", .
  • ( "1.1", , , )

, , , ( ) ( , ), , , . , , , - - LDAP .

. (0), , , , , ( , , ), , .

, , SearchResultEntries SearchResultReferences, , , SearchResultDone - API , .

, : ", -, ", . API "" .

+1

All Articles