{"id":115,"date":"2024-02-16T21:33:31","date_gmt":"2024-02-16T20:33:31","guid":{"rendered":"https:\/\/thurow.de\/?p=115"},"modified":"2024-02-16T21:56:04","modified_gmt":"2024-02-16T20:56:04","slug":"ldap-client-in-net-zu-openldap","status":"publish","type":"post","link":"https:\/\/thurow.de\/?p=115","title":{"rendered":"LDAP-Client in .Net zu openldap"},"content":{"rendered":"\n<p>Leider unterscheiden sich mal wieder die Netzwerkstacks von Windows und Linux auch bei LDAP. \u00dcber System.DirectoryServices.Protocols ist dennoch eine Verbindung m\u00f6glich. Hier ein Codeschnippsel zur Verbindung mit einem openldap-Server via TLS.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System.DirectoryServices.Protocols;\n\nLdapDirectoryIdentifier id = new(ldapServerName, ldapServerPort);\nusing (LdapConnection connection = new(id) { AuthType = AuthType.Basic })\n{\n    \/\/ required for searching on root of ldap directory https:\/\/github.com\/dotnet\/runtime\/issues\/64900\n    connection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;\n\n    \/\/ must be version 3 for TLS. TLS is not supported in version 2.\n    connection.SessionOptions.ProtocolVersion = 3;\n\n    \/\/ use TLS\n    connection.SessionOptions.StartTransportLayerSecurity(null);\n\n    NetworkCredential credential = new(ldapServerUser, ldapServerPwd);\n    connection.Bind(credential);\n    ...\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Leider unterscheiden sich mal wieder die Netzwerkstacks von Windows und Linux auch bei LDAP. \u00dcber System.DirectoryServices.Protocols ist dennoch eine Verbindung m\u00f6glich. Hier [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[11,13,14,12],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-net","category-programmierung","tag-net","tag-c","tag-ldap","tag-programmierung"],"_links":{"self":[{"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thurow.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":5,"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/thurow.de\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/thurow.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thurow.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thurow.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}