Link to home
Start Free TrialLog in
Avatar of 777999
777999

asked on

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

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;
    try
    {
        DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain,
            userName, password);
        object nativeObject = entry.NativeObject;
        authentic = true;
    }
    catch (DirectoryServicesCOMException) { }
    return authentic;
}

Open in new window

Avatar of badbearontour
badbearontour

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....

Regards

BB
 correction...


.... with OUR 'Intranet' user object.....
ASKER CERTIFIED SOLUTION
Avatar of 777999
777999

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial