s***@gmail.com
2005-12-30 21:35:14 UTC
I am accessing the Active Directory from a ASPX page to display the
Active Directory Groups. I have 2 Windows 2003 development server where
the same application is deployed for testing purpose. Accessing the
Active directory groups works fine from one server and gives the
following error on the other server. Both servers are part of the same
active directory domain. I do not see any difference between these two
servers IIS configuration. I am using the following code:
StringCollection groupSrcList = new StringCollection();
DirectoryEntry ent = new
DirectoryEntry(_activeDirectoryParams.ServerPath);
using (ent) // Dispose entry once done
{
DirectorySearcher searcher = new DirectorySearcher(ent);
searcher.PropertiesToLoad.Add(ImportExternalUsersConstants.USER_ATTRIBUTE_CN);
searcher.Filter = _activeDirectoryParams.GroupFilter;
searcher.SearchScope = SearchScope.Subtree;
using (SearchResultCollection src = searcher.FindAll())
{
foreach(SearchResult result in src)
{
foreach( string memberColl in
result.Properties[ImportExternalUsersConstants.USER_ATTRIBUTE_CN])
{
if (null != memberColl)
{
groupSrcList.Add(memberColl);
}
}
}
}
}
return groupSrcList;
If I pass the user name and password in the DirectoryEntry constructor
then it solves the problem. But I need to know at what situation I
should pass the user name and password so that our customers do not
have this issue. I appreciate if some one can help me to figure this
out!
ERROR I get is:
An operations error occurred
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An
operations error occurred
Source Error:
Line 113: searcher.Filter = _activeDirectoryParams.GroupFilter;
Line 114: searcher.SearchScope = SearchScope.Subtree;
Line 115: using (SearchResultCollection src = searcher.FindAll())
Line 116: {
Line 117: foreach(SearchResult result in src)
Source File:
c:\mercury\plugins\authentication\activedirectory\activedirectoryhelper.cs
Line: 115
Stack Trace:
[COMException (0x80072020): An operations error occurred]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
+705
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObject() +10
System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +199
System.DirectoryServices.DirectorySearcher.FindAll() +10
Inmagic.Mercury.Plugins.Authentication.ActiveDirectory.ActiveDirectoryHelper.GetActiveDirectoryGroups()
in
c:\mercury\plugins\authentication\activedirectory\activedirectoryhelper.cs:115
Inmagic.Mercury.Plugins.Authentication.ActiveDirectory.ActiveDirectory.GetGroups()
in
C:\Mercury\Plugins\Authentication\ActiveDirectory\ActiveDirectory.cs:78
Inmagic.Mercury.Components.Authentication.AuthenticationPluginManager.GetGroups()
in
C:\Mercury\Components\Authentication\AuthenticationPluginManager.cs:183
Active Directory Groups. I have 2 Windows 2003 development server where
the same application is deployed for testing purpose. Accessing the
Active directory groups works fine from one server and gives the
following error on the other server. Both servers are part of the same
active directory domain. I do not see any difference between these two
servers IIS configuration. I am using the following code:
StringCollection groupSrcList = new StringCollection();
DirectoryEntry ent = new
DirectoryEntry(_activeDirectoryParams.ServerPath);
using (ent) // Dispose entry once done
{
DirectorySearcher searcher = new DirectorySearcher(ent);
searcher.PropertiesToLoad.Add(ImportExternalUsersConstants.USER_ATTRIBUTE_CN);
searcher.Filter = _activeDirectoryParams.GroupFilter;
searcher.SearchScope = SearchScope.Subtree;
using (SearchResultCollection src = searcher.FindAll())
{
foreach(SearchResult result in src)
{
foreach( string memberColl in
result.Properties[ImportExternalUsersConstants.USER_ATTRIBUTE_CN])
{
if (null != memberColl)
{
groupSrcList.Add(memberColl);
}
}
}
}
}
return groupSrcList;
If I pass the user name and password in the DirectoryEntry constructor
then it solves the problem. But I need to know at what situation I
should pass the user name and password so that our customers do not
have this issue. I appreciate if some one can help me to figure this
out!
ERROR I get is:
An operations error occurred
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An
operations error occurred
Source Error:
Line 113: searcher.Filter = _activeDirectoryParams.GroupFilter;
Line 114: searcher.SearchScope = SearchScope.Subtree;
Line 115: using (SearchResultCollection src = searcher.FindAll())
Line 116: {
Line 117: foreach(SearchResult result in src)
Source File:
c:\mercury\plugins\authentication\activedirectory\activedirectoryhelper.cs
Line: 115
Stack Trace:
[COMException (0x80072020): An operations error occurred]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
+705
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObject() +10
System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +199
System.DirectoryServices.DirectorySearcher.FindAll() +10
Inmagic.Mercury.Plugins.Authentication.ActiveDirectory.ActiveDirectoryHelper.GetActiveDirectoryGroups()
in
c:\mercury\plugins\authentication\activedirectory\activedirectoryhelper.cs:115
Inmagic.Mercury.Plugins.Authentication.ActiveDirectory.ActiveDirectory.GetGroups()
in
C:\Mercury\Plugins\Authentication\ActiveDirectory\ActiveDirectory.cs:78
Inmagic.Mercury.Components.Authentication.AuthenticationPluginManager.GetGroups()
in
C:\Mercury\Components\Authentication\AuthenticationPluginManager.cs:183