Verify User's credentials

  • Thread starter Thread starter John Beschler
  • Start date Start date
J

John Beschler

I am developing a WEB-based employee evaluation app that reuires the
supervisor and employee have a "face-to-face". To confirm that this has been
accomplished, I want to have a form that the employee and the supervisor will
both "sign" electronically during the same session. To do that, obviously, I
need to validate both users.

My plan is to allow the users to enter their AD usernames/passwords and
validate them against the domain. I have found a few examples of how to do
that using VB but none using C#. Can anyone help me with this please?

Thanks,
John
 
Thanks Mark. That worked perfectly!

Mark Rae said:
using System;
using System.Collections.Generic;
using System.DirectoryServices;

/// <summary>
/// Validates a logon request against the current domain
/// </summary>
/// <param name="pstrUser">User account without domain name</param>
/// <param name="pstrPassword">Password</param>
/// <returns>Boolean</returns>
bool Logon(string pstrUser, string pstrPassword)
{
try
{
using (DirectoryEntry objADEntry = new DirectoryEntry("LDAP://" +
System.Environment.UserDomainName, pstrUser, pstrPassword))
{
return !objADEntry.NativeObject.Equals(null);
}
}
catch (System.Runtime.InteropServices.COMException)
{
return false;
}
catch (Exception)
{
throw;
}
}
 
Back
Top