locked
AD problem System.Runtime.InteropServices.COMException: An operations error occurred. RRS feed

  • Question

  • User-526243309 posted

    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

    Tuesday, December 22, 2009 6:48 AM

All replies

  • User-1924116800 posted

    Hey..

    Did you get any solution to this error ? 

    Could you please letme know, if you have any solution for this ?

    Regards,

    -Ravi.

     

    Wednesday, February 10, 2010 8:21 AM
  • User-665654804 posted

    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 

    Saturday, May 22, 2010 5:57 AM