Pardus 19, Debian 10 Üzerindeki Dotnet Core 2.2 İle LDAP Doğrulaması (LDAP Authentication with Dotnet Core 2.2 on Pardus 19, Debian 10)
Maalesef henüz Linux cihazlar üzerinden LDAP doğrulaması için core ekibinin bir çalışması yok. O sebepten 3. Parti paketle (Novell (R)) yaptık. (Unfortunately, the core team has not yet worked on LDAP validation over Linux devices. That’s why we made a 3rd party package (Novell (R)).) 1. Paketi projeye ekleyin. (Adding the package to the project.)dotnet add package Novell.Directory.Ldap.NETStandard2_0
touch ldap.cs
using Novell.Directory.Ldap; namespace Ldap_02 { public class LDAP { public static string AuthenticateUser(string pLdapHost, string pLoginDN, string pPassword) { int ldapPort = LdapConnection.DEFAULT_PORT; int ldapVersion = LdapConnection.Ldap_V3; LdapConnection conn = new LdapConnection(); try { conn.Connect(pLdapHost, ldapPort); conn.Bind(ldapVersion, pLoginDN, pPassword); conn.Disconnect(); return ("Tamam"); } catch (LdapException e) { if (e.ResultCode == LdapException.NO_SUCH_OBJECT) { return ("No such entry" + " (" + e.ResultCode + ")."); } else if (e.ResultCode == LdapException.NO_SUCH_ATTRIBUTE) { return ("No such attribute" + " (" + e.ResultCode + ")."); } else { return (e.ToString() + " (" + e.ResultCode + ")."); } } catch (System.IO.IOException e) { return (e.ToString() + "(IO Exception)"); } } } }
String ldapHost = "mydomain.local"; String loginDN = "test@mydomain"; String password = "GüçlüŞifre"; if(LDAP.AuthenticateUser(ldapHost, loginDN, password) == "Tamam"){ }else{ };