From: Clifford Heath Date: 2007-04-25T08:35:05+09:00 Subject: Re: Retrieving Groups from a DSQUERY anon1m0us wrote: > I need a list of all the groups a user is part of. When I do the > DSQuery in returns a bunch of groups. I need to capture the group > names. > All groups start with CN=group name and end with a comma. > How to I capture the group name only, which starts after CN= and ends > at the FIRST comma?? Actually it doesn't end at the first comma - you could have a backslashed comma inside the group's CN. I recsll doing it something like this: group_dn ='CN=Users\, Group,OU=farnarkle' group_cn = group_dn.sub(/CN=((:?[^\\,]|\\.)*).*/, $1) puts group_cn Users\, Group This matches the name as a sequence of either a single backslashed character, or a char that's not either a backslash or a comma. Note that the result is still LDAP-escaped. Clifford Heath.