Verify User's credentials

Discussion in 'ASP .Net' started by John Beschler, Sep 18, 2009.

  1. 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
     
    John Beschler, Sep 18, 2009
    #1
    1. Advertising

  2. Thanks Mark. That worked perfectly!

    "Mark Rae [MVP]" wrote:

    > "John Beschler" <> wrote in message
    > news:...
    >
    > > 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?

    >
    > 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;
    > }
    > }
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
     
    John Beschler, Sep 18, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QW5kcmV3?=

    What is the best approach to verify a user?

    =?Utf-8?B?QW5kcmV3?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    415
    Kevin Spencer
    Nov 3, 2005
  2. David Bear

    verify a user

    David Bear, Jan 19, 2006, in forum: Python
    Replies:
    1
    Views:
    327
    Dan Sommers
    Jan 19, 2006
  3. asimhg
    Replies:
    0
    Views:
    911
    asimhg
    Feb 4, 2010
  4. Guest

    Verify User Group from ASP.NET

    Guest, Jun 24, 2004, in forum: ASP .Net Security
    Replies:
    4
    Views:
    254
    Joe Kaplan \(MVP - ADSI\)
    Jun 25, 2004
  5. John Apps
    Replies:
    0
    Views:
    188
    John Apps
    May 19, 2008
Loading...

Share This Page