Re: NTLM authentication



"Mark Rae" <mark@xxxxxxxxxxxxxxxxx> wrote in message news:%23KJnvM$LHHA.3952@xxxxxxxxxxxxxxxxxxxxxxx
"webrod" <rodolphe.aoustin@xxxxxxxxx> wrote in message news:1167909149.759083.317590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Actually, I have users who belong to a domain (WinNT).
So I have users in the SAM database.
Now what I want is to check that a user really exists in this DB with a
.NET script.
So I would like a way to query the SAM database OR to bind the SAM
database.

Is *that* all you want to do...? I.e. validate a login and password...?

Why don't you just do this:

using System.DirectoryServices;

public static bool Logon(string pstrDomain, string pstrUser, string pstrPassword)
{
try
{
using (DirectoryEntry objADEntry = new DirectoryEntry("LDAP://"; + pstrDomain, pstrUser, pstrPassword))
{
return !objADEntry.NativeObject.Equals(null);
}
}
catch (System.Runtime.InteropServices.COMException)
{
return false;
}
catch (Exception)
{
throw;
}
}




Won't work, the OP is in a Windows NT4 domain not an ActiveDirectory domain, there is no LDAP server on the DC. Also, using above (DirectoryServices aka. ActiveDirectory) to authenticate a windows user is bad practice, I keep saying this.

Willy.

.