asp.net + c# -> HttpContext.Current.User + directoryentry

Discussion in 'ASP .Net Security' started by Nicopilami, Mar 13, 2008.

  1. Nicopilami

    Nicopilami Guest

    Hi everybody

    i'm trying to open a directory services connection under the
    users' (who is navigating the webpage) credentials, like
    impersonation, but i don't succeed, could you help me ?

    the problematic line is the following :

    DirectoryEntry Ldap = new DirectoryEntry(ConnexionAD,
    ADusername, ADpassword);

    actually, i would like to retrieve ADusername and ADpassword from
    HTTPcontext.current.user becaus the user is authenticated by forms. Is
    there a way for doing that ?

    thx by advance
    Nico
    Nicopilami, Mar 13, 2008
    #1
    1. Advertising

  2. Nicopilami

    Joe Kaplan Guest

    You don't have Windows credentials of the logged on user to impersonate when
    you use forms authentication and the user's password is not available to you
    in general as it is only captured during the login. In order to get those
    credentials, you'll need to capture them during the forms auth login and
    store them somewhere in a safe way so they can be retrieved later.

    You could also consider switching to Windows auth instead.

    Joe K.
    --
    Joe Kaplan-MS MVP Directory Services Programming
    Co-author of "The .NET Developer's Guide to Directory Services Programming"
    http://www.directoryprogramming.net
    --
    "Nicopilami" <> wrote in message
    news:...
    > Hi everybody
    >
    > i'm trying to open a directory services connection under the
    > users' (who is navigating the webpage) credentials, like
    > impersonation, but i don't succeed, could you help me ?
    >
    > the problematic line is the following :
    >
    > DirectoryEntry Ldap = new DirectoryEntry(ConnexionAD,
    > ADusername, ADpassword);
    >
    > actually, i would like to retrieve ADusername and ADpassword from
    > HTTPcontext.current.user becaus the user is authenticated by forms. Is
    > there a way for doing that ?
    >
    > thx by advance
    > Nico
    Joe Kaplan, Mar 14, 2008
    #2
    1. Advertising

  3. Nicopilami

    Nicopilami Guest

    On 14 mar, 15:30, "Joe Kaplan"
    <> wrote:
    > You don't have Windows credentials of the logged on user to impersonate when
    > you use forms authentication and the user's password is not available to you
    > in general as it is only captured during the login. In order to get those
    > credentials, you'll need to capture them during the forms auth login and
    > store them somewhere in a safe way so they can be retrieved later.
    >
    > You could also consider switching to Windows auth instead.
    >
    > Joe K.
    > --
    > Joe Kaplan-MS MVP Directory Services Programming
    > Co-author of "The .NET Developer's Guide to Directory Services Programming"http://www.directoryprogramming.net
    > --"Nicopilami" <> wrote in message
    >
    > news:...> Hi everybody
    >
    > > i'm trying to open a directory services connection under the
    > > users' (who is navigating the webpage) credentials, like
    > > impersonation, but i don't succeed, could you help me ?

    >
    > > the problematic line is the following :

    >
    > > DirectoryEntry Ldap = new DirectoryEntry(ConnexionAD,
    > > ADusername, ADpassword);

    >
    > > actually, i would like to retrieve ADusername and ADpassword from
    > > HTTPcontext.current.user becaus the user is authenticated by forms. Is
    > > there a way for doing that ?

    >
    > > thx by advance
    > > Nico


    ok, that's what i've finally done, stored into the session variables,
    as encrypted variable; it's not very beautiful, but it works well :eek:)

    thx
    bye
    Nico
    Nicopilami, Mar 17, 2008
    #3
    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. Mike Newton
    Replies:
    0
    Views:
    2,884
    Mike Newton
    Jul 23, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,611
    Steve C. Orr [MVP, MCSD]
    Jul 23, 2004
  3. nalbayo
    Replies:
    2
    Views:
    5,491
    Bruce Barker
    Nov 11, 2005
  4. Dwight Johnson

    HttpContext.Current.User returns old user id

    Dwight Johnson, Feb 16, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    1,273
    Alexey Smirnov
    Feb 28, 2010
  5. Tony

    Dim context As HttpContext = HttpContext.Current

    Tony, Mar 2, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    305
    Teemu Keiski
    Mar 3, 2004
Loading...

Share This Page