Solved

Can I create a vbs script the will use DSQuery and DSGet to find if a user is in a group?

Posted on 2007-11-13
3
2,247 Views
Last Modified: 2012-05-05
Can I create a vbs script the will use DSQuery and DSGet to find if a user is in a group?

What I want to do is take user ids from a txt file and first use DSQuery to see if they are in the Domain then use DSGet to see if they are in a group. If they are not in the group out put the user ID to a text file.

So is this doable in a vbs script?
0
Comment
Question by:pointhigh
3 Comments
 
LVL 11

Expert Comment

by:bsharath
ID: 20277278
Is it that you want to find users in the txt file if they are a member of any group.?
0
 
LVL 3

Accepted Solution

by:
elissaqp earned 250 total points
ID: 20277551
This is an example of "Returns the members of an Active Directory group named Scientists."

On Error Resume Next
 
Set objGroup = GetObject _
  ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo
 
arrMemberOf = objGroup.GetEx("member")
 
WScript.Echo "Members:"
For Each strMember in arrMemberOf
  WScript.echo strMember
Next


If you need to write info on a txt file, this is an example:

Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\service_status.txt", ForAppending, True)
Set colServices =  GetObject("winmgmts:").ExecQuery _
    ("Select * from Win32_Service")
For Each objService in colServices    
    objTextFile.WriteLine(objService.DisplayName & vbTab & _
        objService.State)
Next
objTextFile.Close

0
 

Author Comment

by:pointhigh
ID: 20289820
That looks like a good solution
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now