S
sekhar mantrala via .NET 247
I too got the same problem accessing the active directory while trying from a webpart in share point portal server. The sample code is as follows...
DirectoryEntry entry = new DirectoryEntry("GC://corp.microsoft.com");
DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = ("(&(objectClass=user)(SAMAccountName= " + UserAlias + "))");
SearchResultCollection result = dSearch.FindAll(); //////////the error occurs here
dSearch.PropertiesToLoad.Add("samaccountname");
foreach(SearchResult sResultSet in dSearch.FindAll()) ////////the error occurs here
The same code works fine in a seperate web application/windows application.
Can anyone have any idea why this happens and help me in identifying the issue?
Thanks in advance
DirectoryEntry entry = new DirectoryEntry("GC://corp.microsoft.com");
DirectorySearcher dSearch = new DirectorySearcher(entry);
dSearch.Filter = ("(&(objectClass=user)(SAMAccountName= " + UserAlias + "))");
SearchResultCollection result = dSearch.FindAll(); //////////the error occurs here
dSearch.PropertiesToLoad.Add("samaccountname");
foreach(SearchResult sResultSet in dSearch.FindAll()) ////////the error occurs here
The same code works fine in a seperate web application/windows application.
Can anyone have any idea why this happens and help me in identifying the issue?
Thanks in advance