title: userprinciple.FindByIdentity succeeds on one server but not another
body: <p>I have been tasked with migrating some c# v4 apps from one server to another, and I have hit an issue with one of the aspx forms.</p>
  
  <p>The form has the a call to a class to search for an AD user in its code behind file. The method it calls is below.</p>
  
  <pre><code>    public UserPrincipal GetADUser(string samAccountName)
          {
          try
          {
              UserPrincipal user = UserPrincipal.FindByIdentity(AD.domainContext, samAccountName);
              return user;
          }
          catch(Exception ex)
          {
              throw new Exception(" Cant perform this operation:-"+ex.Message);
          }
      }
  </code></pre>
  
  <p>AD.domainContext is defined below</p>
  
  <p><code>private static PrincipalContext domainContext = new PrincipalContext(ContextType.Domain,  ConfigurationHandler._ADDomain);</code></p>
  
  <p>My problem is that the method works on 2 of my servers (VS Dev and the server currently running the code that im migrating from) and throws an exception on the server im trying to migrate to. All the server are identical environments Windows Server 2k8 R2 running iis 7.5 </p>
  
  <p>The error that is being thrown is </p>
  
  <p><strong>Cant perform this operation:-An operations error occurred.</strong></p>
  
  <p>i have had a search and found the following stackoverflow issues but none seem to resolve the issue</p>
  
  <p><a href="https://stackoverflow.com/questions/3507476/system-directoryservices-accountmanagement-principalcontext-and-impersonation-in">System.DirectoryServices.AccountManagement.PrincipalContext and Impersonation in a WCF service</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7285503/active-directory-com-exception-an-operations-error-occured-0x80072020">Active Directory COM Exception - An operations error occurred (0x80072020)</a></p>
  
  <p>Does anyone have any idea what would be causing this error to be thrown on one environment and not any other ?</p>
  
  <p>I have tried to debug the code and it works fine in VS debug, however when the code is deployed to the said server is when i get the issue.</p>
  
  <p>Any help, thoughts, ideas would be much appreciate.</p>
  
  <p>If i have forgotten to include anything i am happy to elaborate on any of the information provided.</p>
  
  <p>Thanks in advance</p>
  
  <p>Nicholas</p>