Verify User's credentials

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
 
J

John Beschler

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top