How search user in Active Directory and then find it in a table's Aplication with c# ?

Posted on 2009-04-29
Last Modified: 2012-05-06
Hi everyone:

I need to make a login that must make the follow:
1- When the user is connected to the INTRANET, is in Active Directory where they need to put the user name and password.
2.- Once the user is inside the INTRANET, he can go to his explorer, open a Web Page and he'll never enter the username and Password BUT:
a) Behind in the background the user send to the server his username and password from the sesion when he entered to the INTRANET, then:
b) If the username and password in the Active Directory are correct, the aplication return a true and then this same username and passworda are:
c) Are searched in the tables of the application that we are development, if this final step are true then:
d) Return true and the username and password are saved in a Session variable

500 Point to this SOLUTION, thank you so much.

In the example below, this code receive the username and password, BUT where I can get the username and password if this are posting where the user are enter to INTRANET?
private bool Authenticate(string userName,

    string password, string domain)


    bool authentic = false;



        DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain,

            userName, password);

        object nativeObject = entry.NativeObject;

        authentic = true;


    catch (DirectoryServicesCOMException) { }

    return authentic;


Open in new window

Question by:777999
    LVL 7

    Expert Comment

    just a comment rather than a solution, I would be wary of storing the password in a session variable......

    its retrievable from the served webpage, using base64 decoding.....

    just a thought....

    I used a similar system, but simply got AD to authenticate my user, after that we only ever dealt with out 'intranet' user object, which did not have access or indeed knowledge of the password for the user....


    LVL 7

    Expert Comment


    .... with OUR 'Intranet' user object.....

    Accepted Solution

    badbearontour:, Thanks for aswering but that wasn't the solution

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now