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
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
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>
Re: how to retrieve active directory objects
Dear Mendhak,
Thanks for your reply. How can I retrieve user name and password from Windows Authentication.
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.
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.
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.
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.
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 ;)
Re: how to retrieve active directory objects
The naming convention you used was so long I fell asleep halfway through reading it.