title: PrincipalContext: Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred
body: <p>I am trying to search AD for a user, but it keeps throwing an exception.  The application is setup to use AppPool. and I am certain that the logged in user has access to search AD.</p>
  
  <p>Code:</p>
  
  <pre><code>public static UserADInfoModel ResolveUserProperties(string sam)
          {
              UserADInfoModel uad = new UserADInfoModel();
              PrincipalContext DC = new PrincipalContext(ContextType.Domain, 
              "lm.lmig.com", "DC=lm,DC=lmig,DC=com,OU=LM Users");
              UserPrincipal userSearch = new UserPrincipal(DC);
              userSearch.SamAccountName = "(&amp;(objectClass=user)(sam)";
              PrincipalSearcher search = new PrincipalSearcher();
              search.QueryFilter = userSearch;
              PrincipalSearchResult&lt;Principal&gt; res = search.FindAll();
  </code></pre>
  
  <p>stack trace:</p>
  
  <pre><code>[DirectoryServicesCOMException (0x80072020): An operations error occurred.
  ]
     System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +399003
     System.DirectoryServices.DirectoryEntry.Bind() +36
     System.DirectoryServices.DirectoryEntry.get_SchemaEntry() +35
     System.DirectoryServices.AccountManagement.ADStoreCtx.IsContainer(DirectoryEntry de) +47
     System.DirectoryServices.AccountManagement.ADStoreCtx..ctor(DirectoryEntry ctxBase, Boolean ownCtxBase, String username, String password, ContextOptions options) +116
     System.DirectoryServices.AccountManagement.PrincipalContext.CreateContextFromDirectoryEntry(DirectoryEntry entry) +143
     System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit() +244
  </code></pre>
  
  <p>Source Error: </p>
  
  <pre><code>Line 45:             PrincipalContext DC = new PrincipalContext(ContextType.Domain, "lm.lmig.com", "DC=lm,DC=lmig,DC=com,OU=LM Users");
  Line 46:             UserPrincipal userSearch = new UserPrincipal(DC);
  Line 47:             userSearch.SamAccountName = "(&amp;(objectClass=user)(sam)";
  Line 48:             PrincipalSearcher search = new PrincipalSearcher();
  Line 49:             search.QueryFilter = userSearch;
  </code></pre>