Results 1 to 10 of 10

Thread: how to retrieve active directory objects

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    how to retrieve active directory objects

    Hi,

    I want to develop an application in which I can use active directory objects. How can I retrieve user name, password and Domain from the active directory? I want to log on my software using the active directory user name and password.

    I am using .NET 2003 and framework 1.1 .


    Thanking you,
    Zahir

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: how to retrieve active directory objects

    You would use classes in System.DirectoryServices to interact with your AD...
    Sample code can be found here
    http://www.c-sharpcorner.com/UploadF...Directory.aspx

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to retrieve active directory objects

    Quote Originally Posted by zisohel
    Hi,

    I want to develop an application in which I can use active directory objects. How can I retrieve user name, password and Domain from the active directory? I want to log on my software using the active directory user name and password.

    I am using .NET 2003 and framework 1.1 .


    Thanking you,
    Zahir
    Then just set Windows Authentication in IIS for your application. You don't need to go diving into AD>

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Re: how to retrieve active directory objects

    Dear Mendhak,

    Thanks for your reply. How can I retrieve user name and password from Windows Authentication.

  5. #5
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: how to retrieve active directory objects

    You can only get the username - you will never be able to retrieve the password unless you're using forms authentication. Which you're not :P

    As for retrieving the Windows username:
    1) Ensure that the <identity> element in your web.config has the attribute "impersonate" set to "true" (i.e. <identity impersonate="true" />). See the MSDN documentation for more information.
    2) Ensure that anonymous access is disabled in IIS.
    3) The fully qualified username is available in the System.Web.HttpContext.Current.User.Identity.Name property.

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Re: how to retrieve active directory objects

    Thanks axion_sa it works. You said unless using the form authentication I can't retrieve the password. How can I retrieve the password from the Form authentication? I want to verrify the user name and password from the active directory.

  7. #7
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: how to retrieve active directory objects

    If your code is running, IIS has already authenticated the user - which is the point of integrated/Windows authentication; you don't need to worry about credential storage nor authentication mechanisms. For all intents & purposes, "it just happens" - it's a lovely little blackbox.

    Simply put - you do not need the user's password.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to retrieve active directory objects

    For the purpose of storing in your session variable, if you need that for other parts of your application, use User.Identity.Name.

  9. #9
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: how to retrieve active directory objects

    Quote Originally Posted by mendhak
    For the purpose of storing in your session variable, if you need that for other parts of your application, use User.Identity.Name.
    Erm... point 3 above

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to retrieve active directory objects

    The naming convention you used was so long I fell asleep halfway through reading it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width