title: Trying to use DirSync on a specific OU in Active Directory
body: <p>I am trying to use DirSync to get all changes to users in a particular OU (using C#).  From what I've read, the root of the search must be the root of the directory partition, so I'm initializing my DirectoryEntry using the path:</p>
  
  <pre><code>string strUserDirPath = "LDAP://xxx.yyy.zzz/DC=xxx,DC=yyy,DC=zzz";
  </code></pre>
  
  <p>and then later I'm trying to set a filter that will give me only users in a specific OU.  </p>
  
  <p>The problem is, whenever I try to add the OU to the filter, it filters everything out.  If I say:</p>
  
  <pre><code>srch.Filter = "(&amp;(objectClass=user)(objectcategory=person))";
  </code></pre>
  
  <p>that gives me all users.  </p>
  
  <p>The full path to the OU I want is:</p>
  
  <pre><code>"OU=aaa,OU=bbb,OU=ccc,OU=ddd,OU=eee,DC=xxx,DC=yyy,DC=zzz"
  </code></pre>
  
  <p>I would like to sync only users that match this complete path.  </p>
  
  <p>I have tried adding several things to my filter to do this, but it always ends up filtering out ALL records.  I have tried the following filters to no avail:</p>
  
  <pre><code>"(&amp;(objectClass=user)(objectcategory=person)(OU=aaa))"
  "(&amp;(objectClass=user)(objectcategory=person)(OU=aaa,OU=bbb,OU=ccc,OU=ddd,OU=eee))"
  "(&amp;(objectClass=user)(objectcategory=person)(OU=aaa,OU=bbb,OU=ccc,OU=ddd,OU=eee,DC=xxx,DC=yyy,DC=zzz))"
  "(&amp;(objectClass=user)(objectcategory=person)(memberof=OU=aaa,OU=bbb,OU=ccc,OU=ddd,OU=eee,DC=xxx,DC=yyy,DC=zzz))"
  "(&amp;(objectClass=user)(objectcategory=person)(memberOf:1.2.840.113556.1.4.1941:=OU=aaa,OU=bbb,OU=ccc,OU=ddd,OU=eee,DC=xxx,DC=yyy,DC=zzz))"
  </code></pre>
  
  <p>I feel like I'm probably missing something very obvious, but can't quite get it.  </p>
  
  <p>Can anyone offer any solutions?  As a last resort, I'm thinking of just getting all users, and then programmatically filtering out the ones I don’t need.  Seems clunky, but if it's what I gotta do, I will.  </p>