tags:

views:

239

answers:

2

I have a query to fetch ad users based on modifytimestamp attribute.

string datetime = acc.ToUniversalTime().ToString("yyyyMMddHHmmss") + ".OZ";
  "(&(objectClass=User)(objectCategory=User)
  (userAccountControl:1.2.840.113556.1.4.803:=2)(modifyTimestamp<=" + datetime + 
  "))";

The above query generate the following error in Windows Server 2008R2, but it works
fine in other Windows Server OS

Error:

   The Server does not support the requested critical extension
   at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.MoveNext()
   at DisabledUsers.Program.GetDisabledUsers(String tag, Int32 days) in C:\Users\hari\Documents\Visual Studio 2010\Projects(C#)\DisabledUsers\DisabledUsers\Program.cs:line 37
   at DisabledUsers.Program.Main(String[] args) in C:\Users\hari\Documents\Visual Studio 2010\Projects(C#)\DisabledUsers\DisabledUsers\Program.cs:line 14
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
A: 

Your pasted code seems to have a semicolon at the end of the first line, which would make the strings on the lower lines not part of anything. If this is not a mistake (or at least just a mistake in your pasting of the code, but not in your original code), I'm not familiar with AD queries, but I have seen DATETIME stamps for UTC end with a single letter "Z" (and haven't seen ".OZ" before). Also, confirm the function doesn't want more characters between the date and time parts (e.g. hyphens between the date parts and colons between the time parts, and a space between, etc.).

Andy Jacobs
A: 

In the posted code, the datetime string on the first line has .OZ (letter O Z) on the end. You want it to be .0Z (zero Z).

Joe Doyle