Use default credentials in order to call DirectoryEntry

Posted by Copeleto on Stack Overflow See other posts from Stack Overflow or by Copeleto
Published on 2010-04-07T20:51:11Z Indexed on 2010/04/07 21:03 UTC
Read the original article Hit count: 394

Hi,

I am working in a Login page and teh logic is like ->

try 
{
    DirectoryEntry LDAPLogin = new DirectoryEntry(ConfigurationSettings.AppSettings ["LDAPPath"].ToString(), Usuario, Txt_Contrasenia.Text.ToString());

    if (LDAPLogin.NativeGuid != LDAPLogin.Name)
       ValidarGrupo();
}
catch (Exception exc)
{
   Label_Info.Text = "Sus credenciales no son validas: " + Usuario.ToString() + " " + exc.Message;
}

If the user enters the rights credentials I call a method ValidarGrupo that implements a lookup in the AD for a group of the user

I would like to replace the username and password with UseDefaultCredentials in order to avoid that the user has to enter the username and password and the Login pages use the credentials of the user that is login on the machine.

© Stack Overflow or respective owner

Related posts about c#3.0

Related posts about active-directory