Suppose I have a .NET Core console app that accepts a user name and password, the app is running on Linux. How can I validate that the user name and password are valid on a Windows domain controller (running on the same network as the Linux machine)?
Thanks to the suggestion from @gabriel-luci, I cobbled together this primitive example of using Novell.Directory.Ldap.NETStandard from others that I found.
using Novell.Directory.Ldap;
using System;
namespace ConsoleApp
{
class Program
{
static void Main()
{
Console.Write("Host: ");
var dc = Console.ReadLine();
Console.Write("Domain\\User: ");
var parts = Console.ReadLine().Split("\\");
var domain = parts[0];
var user = parts[1];
Console.Write("Password: ");
var pass = Console.ReadLine();
try
{
using (var ldap = new LdapConnection { SecureSocketLayer = false })
{
ldap.Connect(dc, LdapConnection.DefaultPort);
ldap.Bind($"{user}@{domain}", pass);
if (!ldap.Bound)
{
Console.Write("Not ");
}
Console.WriteLine("Valid");
}
}
catch (LdapException e)
{
Console.WriteLine(e.Message);
}
}
}
}
It worked just fine from win-x64 and linux-arm when I tested it against a Windows 2012 domain controller runningin a VM..