Search code examples
asp.net-web-apiactive-directoryjwtnovell

ASP.NET Core 5, JWT tokenand Novell AD library


I want to know wheather it is a valid solution to use JWT token and the Novel AD authentication an authorization library in an ASP.NET Core 5 Web API in a Linux server? Are there any examples on it, please?


Solution

  • Yes you can use Novell for Authentication. For authenticating your users you can use Ldap using Novell.Directory.Ldap Package.

    In .csprog file:

    <PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="2.3.8" />
    

    In the configuration:

    "Ldap": {
    "url": "[Ldap URL]",
    "domain": "[Domain Name]"
    }
    

    Code:

    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;
    }