When i try to List the users from Active directory, i get this exception.
Error while processing.System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred at System.DirectoryServices.DirectoryEntry.Bind(Boolean
throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindAll()
The code i used is :
DirectoryEntry de = new DirectoryEntry(_path);DirectorySearcher deSearch =
new DirectorySearcher();
The most likely reason is that the user account in whose context your code is executing (aspnet or network service) does not have sufficient rights. Impersonate a domain account and it should work.
Thank you When i tried with the method with <identity impersonate ="true"> i got the asme issue.
When i used <identity impersonate="true"
userName="registry:HKLM\SOFTWARE\YourApp\identity\ASPNET_SETREG,userName"
password="registry:HKLM\SOFTWARE\YourApp\identity\ASPNET_SETREG,password"/>
I got this error : "Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Unspecified error '
JohnsiRani
0 Points
4 Posts
List Users from Active Directory
Aug 04, 2008 12:14 PM|LINK
When i try to List the users from Active directory, i get this exception.
Error while processing.System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindAll()
The code i used is :
DirectoryEntry de = new DirectoryEntry(_path);DirectorySearcher deSearch = new DirectorySearcher();deSearch.SearchRoot =de;
deSearch.Filter = "(&(objectClass=user) (cn=" + UserName +"))";
SearchResultCollection results = deSearch.FindAll();
But the DirectoyEntry method is getting validated if i use the overloaded method : DirectoryEntry(_path, domainAndUsername, password);
Please advice me.
Prashant Kum...
Star
12528 Points
2024 Posts
Re: List Users from Active Directory
Aug 04, 2008 03:00 PM|LINK
The most likely reason is that the user account in whose context your code is executing (aspnet or network service) does not have sufficient rights. Impersonate a domain account and it should work.
JohnsiRani
0 Points
4 Posts
Re: List Users from Active Directory
Aug 07, 2008 02:23 PM|LINK
Thanks for your response.
I am new to Active directory can you please tell me the step by step procedure to " Impersonate a domain account ".
Thank in advance.
Prashant Kum...
Star
12528 Points
2024 Posts
Re: List Users from Active Directory
Aug 07, 2008 11:35 PM|LINK
You can check the following
http://msdn.microsoft.com/en-us/library/xh507fc5(VS.71).aspx
For page level impersonation using web.config
http://msdn.microsoft.com/en-us/library/aa302435.aspx
To implement it programmatically
http://aspnet101.com/aspnet101/tutorials.aspx?id=68
JohnsiRani
0 Points
4 Posts
Re: List Users from Active Directory
Aug 08, 2008 10:54 AM|LINK
Thank you When i tried with the method with <identity impersonate ="true"> i got the asme issue.
When i used <identity impersonate="true"
userName="registry:HKLM\SOFTWARE\YourApp\identity\ASPNET_SETREG,userName"
password="registry:HKLM\SOFTWARE\YourApp\identity\ASPNET_SETREG,password"/>
I got this error : "Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Unspecified error '
Thank you very much for your reply !
Prashant Kum...
Star
12528 Points
2024 Posts
Re: List Users from Active Directory
Aug 09, 2008 01:18 AM|LINK
Try this
<identity impersonate="true" userName="domain\someUserName" password="password"/>
Here domain is the name of the domain in which a user someUserName exists.
JohnsiRani
0 Points
4 Posts
Re: List Users from Active Directory
Aug 11, 2008 11:23 AM|LINK
The same exception is coming at this method. The error which i mentioned at first. SearchResultCollection results = deSearch.FindAll()
ledo_moon
Member
48 Points
47 Posts
Re: List Users from Active Directory
Dec 09, 2009 12:14 PM|LINK
Create Active Directory Service using WCF – Accusing AD Functions using WCF Services – AD Services
http://ledomoon.blogspot.com/2009/12/create-active-directory-service-using.html