Re: How do I filter an Active Directory search to an OU (organizational unit)?

From: Jeff Connelly (nomail_at_thank.you)
Date: 04/13/05


Date: Wed, 13 Apr 2005 15:45:43 -0400


"JohnH." <john@jrcc.net> wrote in message
news:1113420053.573364.223360@l41g2000cwc.googlegroups.com...
> Hi,
>
> I need to be able to retrieve a list of the users in an OU. The
> following C# code works just fine and dumps out a list of all of the
> user objects in all OUs in our active directory. I have not been able
> to figure out the filtering syntax to get this to just display the
> users in an OU. If anybody has any suggestions I'd be very
> appreciative. I've searched the online help, web, and news groups.
> I must not be understanding some fundamental concept here because
> nothing I have tried has worked.
>
> using System;
> using System.DirectoryServices;
>
> namespace ADSearch
> { public class ADRead
> {
> static void Main(string[] args)
> {
> DirectoryEntry entry = new DirectoryEntry
> ("LDAP://jrcc.local");

I think the easiest thing to do here would be to refine your LDAP string.
(LDAP syntax is confusing because several different looking syntaxes are
allowed - it's not consistent. I'll show you one syntax that should work -
there are others.) Let's say you had on the jrcc.local domain an OU called
MyBusiness (common), and then below that an OU called Users. You would use
LDAP://OU=Users,OU=MyBusiness,DC=jrcc,DC=local

That sets your LDAP path to point to that node, your filter does the rest of
the work. Although you might find you don't need your filter anymore.



Relevant Pages

  • Re: Shrink large file according to REG_EXP
    ... I've as input a large text file which I need to filter ... different syntax, and I have syntax files which tell me how to split ... split the file in chunks and let each thread work on a chunk of the ... If your program is I/O bound, then it might be faster to work on ...
    (comp.lang.perl.misc)
  • Re: get opacity value [a bit more]
    ... The latter is being changed now to follow CSS 2.1 Syntax: ... there does appear to be a "need" for a third isHost* function. ... The other one mentioned is designed to filter ... ActiveX objects, so it is used for properties that may need to be ...
    (comp.lang.javascript)
  • Re: Form filter works in 2000-2002 but fails in 2003
    ... There have been other reported problems with Access 2003 not recognising ... >I have a client with an Access 2000 format database sitting on a shared ... > The form's filter looks like this: ... > reference syntax change in 2003 that would cause this? ...
    (microsoft.public.access.forms)
  • Re: Why python doesnt use syntax like function(,,x) for default parameters?
    ... def ChooseItems(StartDate, EndDate, Filter): ... #function returns a set of some items in chronological order ... ChooseItems(, '01.01.2000') #get everything before a date ... I understand that many do not need such a syntax, ...
    (comp.lang.python)
  • Re: Why python doesnt use syntax like function(,,x) for default parameters?
    ... def ChooseItems(StartDate, EndDate, Filter): ... #function returns a set of some items in chronological order ... ChooseItems(, '01.01.2000') #get everything before a date ... I understand that many do not need such a syntax, ...
    (comp.lang.python)

Quantcast