From: "Peña, Botp" Date: 2007-04-25T13:15:20+09:00 Subject: Re: Retrieving Groups from a DSQUERY From: Clifford Heath [mailto:no.spam@please.net] : # It sounds like the OP already did that. arggh, mea culpa. you're right, in fact, after reading again th op, my sample was totally wrong. He was asking what groups the user belong to and my sample just plain listed all the groups and users (of no use really) # This only works for users in CN=Users, even assuming that # you adjust the domain name as appropriate. My solution # gets the CN from any user, whether in CN=Users or not, # without knowing the domain name. # # Hint: many organizations put their users in OU's... The # CN=Users container is really only there for migration # from NT4, so the domain root isn't filled up with users # and computers from the migration. # # It's even legal to put users in a container (CN=) under # an OU, though it's not advised (it's allowed because # that's what CN=Users is). The only correct solution is # to match the RDN component after the user's CN=, up to # the start of the next RDN part, as I showed. Great tip/info there, Clifford. Many thanks -botp ps: Clifford, if by any chance you know how to query a msexchange: I'd like to query all exchange mailboxes and for each mailbox, list all the users who have rights to access it. (since many of us share mailboxes). Pardon the nubiness on windows/exchange..