Я подключаюсь к Ldap с использованием пакета Novell.Directory.Ldap для аутентификации моих пользователей.
Project.csproj
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="2.3.8" />
Code.cs
using Novell.Directory.Ldap;
public bool LoginLdap(string username, string password)
{
LdapConnection connection = new LdapConnection();
var loggedIn = false;
try
{
connection.Connect(_config["Ldap:url"], LdapConnection.DEFAULT_PORT);
connection.Bind(LdapConnection.Ldap_V3, _config["Ldap:domain"] + @"\" + username, password);
loggedIn = true;
}
catch
{
loggedIn = false;
}
connection.Disconnect();
return loggedIn;
}
Config.json
"Ldap": {
"url": "[Ldap URL]",
"domain": "[Domain Name]"
}