Querying AD



Although I'm wrting VB.NET code, the part of the code I'm in need of help on
is AD querying so I figured this group would be more appropriate for the
question.

I'm trying to query AD to see if a username is a member of a group. For some
reason, it only works in a top level OU. Anything below that and it does not
work.

The Problem:

I have a top level OU called testou1. Inside that OU is a group called
testgroup. Within that group is a single user called testuser.

If I run this code (code snipped for brevity), it returns a positive result
by writing the users username to the screen:


osearcher.Filter =
"(&(sAMAccountName=tuser)(memberOf=CN=testgroup,OU=testou1,DC=corp,DC=mydomain,DC=com))"


The above returns the user just fine. Now, if I have a second ou called
testou2 that inside testou1, and I move the group called testgroup from the
OU testou1 to the OU testou2 and I try this code:


osearcher.Filter =
"(&(sAMAccountName=tuser)(memberOf=CN=testgroup,OU=testou1,OU=testou2,DC=corp,DC=mydomain,DC=com))"


I get nothing returned from the query.

I'm hoping someone can clue me in.

TIA,
Jim


.



Relevant Pages

  • Re: Querying AD
    ... The code you posted had testou1 as a sub OU of testou2. ... I'm trying to query AD to see if a username is a member of a group. ... Inside that OU is a group called testgroup. ... If I run this code, it returns a positive result by writing the users username to the screen: ...
    (microsoft.public.windows.server.active_directory)
  • Re: Querying AD [RESOLVED]
    ... The code you posted had testou1 as a sub OU of testou2. ... Joseph T. Corey MCSE, Security+ ... result by writing the users username to the screen: ... and I move the group called testgroup from ...
    (microsoft.public.windows.server.active_directory)