Sometimes a Paged AD request is called.

I have a code (below) that runs every 15 minutes. Sometimes he will not be able to request AD with the following error:

System.DirectoryServices.Protocols.DirectoryOperationException: The server does not support the control. The control is critical. at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout) 
  • When it succeeds, the whole process takes about one minute to complete an AD request, which takes about 30 seconds with 32 pages.
  • When it fails, it is always on the first page.
  • As far as I can tell, it does not work in the template (always different times of the day).

After the error in this error, I found two SO questions ( one , two ) that point to using AuthType.Ntlm to fix the problem. However, this did not solve it for me. Another says to check if the server supports paging (it does).

Any ideas as to why this could be happening?

 var attributesToReturn = new[] { "givenName", "sn", "middleName", "extensionAttribute8", "department", "sAMAccountName", "userAccountControl" }; var filter = "(&(objectclass=user)(!(objectclass=computer))(sn=*)(givenName=*)(extensionAttribute8=*)(|(sn=a*)(sn=b*)(sn=c*)(sn=d*)(sn=e*)(sn=f*)(sn=g*)(sn=h*)(sn=i*)(sn=j*)(sn=k*)(sn=l*)(sn=m*)(sn=n*)(sn=o*)(sn=p*)(sn=q*)(sn=r*)(sn=s*)(sn=t*)(sn=u*)(sn=v*)(sn=w*)(sn=x*)(sn=y*)(sn=z*)))"; var currentBatch = 1; var searchRequest = new SearchRequest("DC=foo,DC=bar,DC=baz", filter, SearchScope.Subtree, attributesToReturn); var pageRequestControl = new PageResultRequestControl(500); searchRequest.Controls.Add(pageRequestControl); using (var ldapConnection = new LdapConnection("server.foo.bar.baz")) { ldapConnection.Credential = new NetworkCredential("user", "pass", "domain"); ldapConnection.Timeout = new TimeSpan(0, 4, 0); ldapConnection.AuthType = AuthType.Ntlm; // https://stackoverflow.com/a/14255413 while (true) { log.Debug("Fetching batch {0} from AD", currentBatch); var searchResponse = (SearchResponse)ldapConnection.SendRequest(searchRequest); var pageResultResponse = (PageResultResponseControl)searchResponse.Controls[0]; log.Debug("Parsing AD response for batch {0}", currentBatch); ParseResponse(_return, searchResponse, includeDisabled); if (pageResultResponse.Cookie.Length == 0) break; pageRequestControl.Cookie = pageResultResponse.Cookie; currentBatch++; } } 
+7
c # active-directory
source share
1 answer

This may not be a problem, as it sometimes fails for you, but each time I got this error and had to install

 ldapConnection.SessionOptions.ProtocolVersion=3 

so that it works at all.

0
source share

All Articles