?
Solved

2003 - AD User & Computers Find Groups

Posted on 2011-03-17
3
Medium Priority
?
306 Views
Last Modified: 2013-11-05
Have a requirement within a large 2003 Domain where I need to search for long named groups from as little as a x3 letter description e.g xyz.  I understand how to use advanced find using end or start words but, there is nothing that works within an advanced search that allow for the scario where you need to find "xyz" within the group string. Does anyone know of a script that will do this ?
0
Comment
Question by:kgeddes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:celborn
ID: 35159923
I recommend using MMC (via active directory addin) especially if you manage more than one active directory domain
0
 

Author Comment

by:kgeddes
ID: 35160021
Sorry but, MMC is not an option in our environment. I was looking for a script.
0
 
LVL 31

Accepted Solution

by:
Justin Owens earned 2000 total points
ID: 35160153
This other Question:

http:/Q_21407686.html

has the following code:
On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=domain,dc=com' WHERE objectCategory='group' "
   
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    Set objType = GetObject(objRecordSet.Fields("ADsPath").Value)
        If objType.GroupType > 0  Then
            Wscript.Echo "Group: " & objType.cn
        End If
    objRecordSet.MoveNext
Loop

Open in new window

with the disclaimer "If you make the GroupType < 0 then it will display only security groups."

In theory, you should be able to add a AND ... LIKE statement to that, like this:
On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=domain,dc=com' WHERE objectCategory='group' AND samAccountName LIKE '%xyz%' "
   
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    Set objType = GetObject(objRecordSet.Fields("ADsPath").Value)
        If objType.GroupType < 0  Then
            Wscript.Echo "Group: " & objType.cn
        End If
    objRecordSet.MoveNext
Loop

Open in new window

samAccountName may need to be samAcctName.  I am not at my lab to test.

DrUltima
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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