0

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?

sada
  • 584
  • 2
  • 8
  • 25

1 Answers1

0

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;
}
Rutha
  • 751
  • 3
  • 7
  • Thank you, but it can be used with JWT bearer token. I want to use it AD authentication and authorization but I do not see example for it and I am not sure to go on the right way. – sada Oct 22 '21 at 08:23
  • 1
    You can implement the Azure AD in your application as guided by this documentation: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/azure-active-directory/?view=aspnetcore-5.0 Then you can implement the Novel in you application by following the Novel doc. – Rutha Oct 23 '21 at 13:32