Query Based Distribution Group based on OU membership

I am trying to create a query based distribution group that simply contains all of the users contained within a particular OU.  Is anybody aware of the Ldap query that will produce this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nirmal SharmaSolution ArchitectCommented:
You can use LDIFDE utility to do so.
Nirmal SharmaSolution ArchitectCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
So you want to create a group based on members in a particular OU ?

What this script will do is first greate a Global Distribution group called "scientists" in the R&D ou in the NA.fabrikam.com domain. We'll give it 5 seconds to do its thing and then we are going to give it a couple of OU's to go through. You can add as many OU'd to the arrOU array as you wish it will go through each one of them and as it gets the members of the OU it will add them to the scientists group. Obviously you need to change the script to fit your needs.

On Error Resume Next


Set objOU = GetObject("LDAP://ou=R&D,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=Scientists")

objGroup.Put "sAMAccountName", "scientists"
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP

Wscript.Sleep 5000

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

arrOU = Array("CN=Builtin,","CN=Users,")

For each mOU in arrOU
    Set objOu = GetObject("LDAP://" & mOU & strDNSDomain)

    For each obj in objOu
       Set objGroup = GetObject ("LDAP://cn=Scientist,OU=R&D,dc=NA,dc=fabrikam,dc=com")
       objGroup.PutEx ADS_PROPERTY_APPEND,"member", Array(obj.name & mOU & strDNSDomain)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.