Visual basic scripting question

Hi all
I am trying to write a new script that gets a group in AD and add one member(domain user) to that group. I have a list 150 user group and members that need to be added in a comma delimited text file. Here is the script that I am using right now :

******************************************************************************************
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\temp\studentmembers.csv", ForReading)
 
Const ADS_PROPERTY_APPEND = 3
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrGrMemList = Split(strNextLine , ",")
 Wscript.Echo "Group Name: ||"&arrGrMemList(0)&"||"
 Wscript.Echo "Member Name: ||"&arrGrMemList(1)&"||"  
Set objGroup = GetObject ("LDAP://cn=" & arrGrMemList(0) & ",ou=Web,ou=CS,dc=abc,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND,"member", Array("cn="& arrGrMemList(1) & ",cn=users,dc=abc,dc=com")
objGroup.SetInfo
Loop
***********************************************************************************

Here arrGrMemList(0) is the user group name and arrGrMemList(1) is the member or user that needs to be added. At this point we have only one member that needs to be added per group.
There is no problem with this script if all the users exist in USERS container. They are spread in some other OU's in the same domain. I dont know how to chance this script to find the user in the entire domain and add it to that group without just looking at just one container or OU.
Also if anybody can give me some links to start with LDAP and AD script writing and understanding how to write these scripts that would be great.

Thanks.
r5ur5Asked:
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.

tone28Commented:

' Prepare Connection
Set oCon = CreateObject("ADODB.Connection")
oCon.Provider = "ADsDSOObject"
oCon.Open "Active Directory Provider"

Base = "<LDAP://dc=abc,dc=com>;"
Attr = "distinguishedName;"
Tree = "SubTree"

' Your Code
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\temp\studentmembers.csv", ForReading)
 On Error Resume Next
Const ADS_PROPERTY_APPEND = 3
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrGrMemList = Split(strNextLine , ",")
 Wscript.Echo "Group Name: ||"&arrGrMemList(0)&"||"
 Wscript.Echo "Member Name: ||"&arrGrMemList(1)&"||"  
Set objGroup = GetObject ("LDAP://cn=" & arrGrMemList(0) & ",ou=Web,ou=CS,dc=abc,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND,"member", Array(GetUsersDN(arrGrMemList(1)))
objGroup.SetInfo
Loop


Function GetUsersDN(UserName)
      
      sfilter = "(&(objectClass=user)(objectCategory=person)(displayName=" & UserName & "));"
      Set oRS = oCon.Execute(Base & sfilter & Attr & Tree)
      
      oRS.MoveFirst
      While Not oRS.EOF
          GetUsersDN = oRS.Fields(0).Value
          oRS.MoveNext
      Wend
End Function
0

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
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
Programming Languages-Other

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.