I have the code below in my site and it works fine when I run the site on our dev server which is Windows Server 2003 IIS6.0 but it doesn't work when I run it on our production server which is Windows Server 2008 IIS 7.0. My authentication mode is set to
windows and identity impersonate is set to true. I have seen several posts on this but none explain why it would work in IIS6 and not IIS7.
Code:
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(sAMAccountName={0})", userName);
search.PropertiesToLoad.Add("givenName");
search.PropertiesToLoad.Add("sn");
SearchResult result = search.FindOne();
Error:
Exception Details: System.Runtime.InteropServices.COMException: An operations error occurred.
Source Error:
Line 20: search.PropertiesToLoad.Add("givenName");
Line 21: search.PropertiesToLoad.Add("sn");
Line 22: SearchResult result = search.FindOne();
Line 23:
Line 24: return (string)result.Properties["givenName"][0] + " " + (string)result.Properties["sn"][0];
ianwebdev
0 Points
1 Post
AD problem System.Runtime.InteropServices.COMException: An operations error occurred.
Dec 22, 2009 10:48 AM|LINK
I have the code below in my site and it works fine when I run the site on our dev server which is Windows Server 2003 IIS6.0 but it doesn't work when I run it on our production server which is Windows Server 2008 IIS 7.0. My authentication mode is set to windows and identity impersonate is set to true. I have seen several posts on this but none explain why it would work in IIS6 and not IIS7.
Code:
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(sAMAccountName={0})", userName);
search.PropertiesToLoad.Add("givenName");
search.PropertiesToLoad.Add("sn");
SearchResult result = search.FindOne();
Error:
Exception Details: System.Runtime.InteropServices.COMException: An operations error occurred.
Source Error:
Line 20: search.PropertiesToLoad.Add("givenName");
Line 21: search.PropertiesToLoad.Add("sn");
Line 22: SearchResult result = search.FindOne();
Line 23:
Line 24: return (string)result.Properties["givenName"][0] + " " + (string)result.Properties["sn"][0];
Stack Trace:
[COMException (0x80072020): An operations error occurred.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +377678
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_AdsObject() +31
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +78
System.DirectoryServices.DirectorySearcher.FindOne() +47
security.GetUserName(String userName) in c:\inetpub\wwwroot\AdminTasks\App_Code\security.cs:22
ASP.global_asax.Session_Start(Object sender, EventArgs e) in c:\inetpub\wwwroot\AdminTasks\Global.asax:12
System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e) +8781440
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +237
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +504
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +66
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
ravi_develop...
Member
4 Points
2 Posts
Re: AD problem System.Runtime.InteropServices.COMException: An operations error occurred.
Feb 10, 2010 12:21 PM|LINK
Hey..
Did you get any solution to this error ?
Could you please letme know, if you have any solution for this ?
Regards,
-Ravi.
aravind.pk
Member
241 Points
79 Posts
Re: AD problem System.Runtime.InteropServices.COMException: An operations error occurred.
May 22, 2010 09:57 AM|LINK
IF this is not yet solved, then requesting you to check this post:
http://forums.asp.net/t/1224607.aspx
And let me know if you find any solution with this.
Thanks