[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2295
  • Last Modified:

csvde output users NOT members of a given group

Hello,

I see that I can use CSVDE to output a list of users in a group. I need to generate a list of all users that are NOT a member of a particular group. I am trying to ID all user accounts in my domain that are not current. I made a current user group and added all my current users. Now I want to generate a list into txt/csv that lists all other user object that are not a member of my current users group.

Thanks!
0
JFTech
Asked:
JFTech
  • 6
  • 4
1 Solution
 
Mike KlineCommented:
I have a blog post about using tools like adfind to do this

http://adisfun.blogspot.com/2009/06/find-users-who-are-not-in-specific.html

You can use that same LDAP query in CSVDE.  You use the -r switch and then the LDAP query

(&(objectcateogry=person)(objectclass=user)(!memberof=DN of group))

Thanks

Mike
0
 
TasmantCommented:
as always mkline comment is perfect, but i would like to complete using the ADS_CHASING_REFERAL to exclude direct and nested members of the specified group:
dsquery * -limit 0 -filter "&(!memberof:1.2.840.113556.1.4.1941:=CN=Domain Admins,CN=Users,DC=eu,DC=airbus,DC=corp)" -attr samaccountname

Open in new window

you can use adfind as said with the filter given in the command-line.
the swith specified by mkline should be -f instead of -r.
0
 
JFTechAuthor Commented:
That did not seem to work for me. Error asking for a input file? What am i doing wrong?

C:\>csvde -r "&(objectcategory=person)(objectclass=user)(!memberof=Current Users) -f c:\current.csv
Invalid Parameter: Input file name required

CSV Directory Exchange

General Parameters
==================
-i              Turn on Import Mode (The default is Export)
-f filename     Input or Output filename
-s servername   The server to bind to (Default to DC of computer's domain)
-v              Turn on Verbose Mode
-c FromDN ToDN  Replace occurences of FromDN to ToDN
-j path         Log File Location
-t port         Port Number (default = 389)
-u              Use Unicode format
-?              Help


Export Specific
===============
-d RootDN       The root of the LDAP search (Default to Naming Context)
-r Filter       LDAP search filter (Default to "(objectClass=*)")
-p SearchScope  Search Scope (Base/OneLevel/Subtree)
-l list         List of attributes (comma separated) to look for in an
                LDAP search
-o list         List of attributes (comma separated) to omit from input.
-g              Disable Paged Search.
-m              Enable the SAM logic on export.
-n              Do not export binary values


Import
======
-k              The import will go on ignoring 'Constraint Violation' and
                'Object Already Exists' errors


Credentials Establishment
=========================
Note that if no credentials is specified, CSVDE will bind as the currently
logged on user, using SSPI.

-a UserDN [Password | *]            Simple authentication
-b UserName Domain [Password | *]   SSPI bind method

Example: Simple import of current domain
    csvde -i -f INPUT.CSV

Example: Simple export of current domain
    csvde -f OUTPUT.CSV

Example: Export of specific domain with credentials
    csvde -m -f OUTPUT.CSV
          -b USERNAME DOMAINNAME *
          -s SERVERNAME
          -d "cn=users,DC=DOMAINNAME,DC=Microsoft,DC=Com"
          -r "(objectClass=user)"
No log files were written.  In order to generate a log file, please
specify the log file path via the -j option.

C:\>
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
JFTechAuthor Commented:
I found your blog started the string with a "&( and your post you gave (&(


C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof=Current Users) -f c:\current.csv
(objectclass was unexpected at this time.


Still errored.....
0
 
Mike KlineCommented:
Are you using the full DN for "current users"

Thanks

Mike
0
 
JFTechAuthor Commented:
Sorry I was not using DN like i should have. I tried it a few different ways after the '=' sign.
I still get an error:


C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof=CN=Current Us
ers,CN=Users,DC=XXXX-IT,DC=NET) -f c:\current.csv
(objectclass was unexpected at this time.

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof= CN=Current U
sers,CN=Users,DC=XXXX-IT,DC=NET) -f c:\current.csv
(objectclass was unexpected at this time.

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberofCN=Current Use
rs,CN=Users,DC=XXX-IT,DC=NET) -f c:\current.csv
(objectclass was unexpected at this time.

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof CN=Current Us
ers SEI,CN=Users,DC=SEI-IT,DC=NET) -f c:\current.csv
(objectclass was unexpected at this time.
0
 
JFTechAuthor Commented:
I missed a closing ' ) ' got it in these but it still errors:

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof=CN=Current Us
ers SEI,CN=Users,DC=SEI-IT,DC=NET)) -f c:\current.csv
(objectclass was unexpected at this time.

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberof= CN=Current U
sers SEI,CN=Users,DC=SEI-IT,DC=NET)) -f c:\current.csv
(objectclass was unexpected at this time.

C:\>csvde -r (&(objectcategory=person)(objectclass=user)(!memberofCN=Current Use
rs SEI,CN=Users,DC=SEI-IT,DC=NET)) -f c:\current.csv
(objectclass was unexpected at this time.
0
 
Mike KlineCommented:
put the query in quotes "(&(....))"

I'll be able to test in about 45 minutes.

It definitely works using adfind  http://adisfun.blogspot.com/2009/06/find-users-who-are-not-in-specific.html

Thanks

Mike
0
 
JFTechAuthor Commented:
Quotes seemed to let it run this time but it gave no out put. I need a list of all users not a member of this current users group. Thanks for helping!!

C:\>csvde -r "(&(objectcategory=person)(objectclass=user)(!memberof CN=Current U
sers SEI,CN=Users,DC=SEI-IT,DC=NET))" -f c:\current.csv
Connecting to "(null)"
Logging in as current user using SSPI
Exporting directory to file c:\current.csv
Searching for entries...
Writing out entries

No Entries found

The command has completed successfully
0
 
Mike KlineCommented:
Try

!memberof=CN=Current U

You forgot that one "=" sign

Thanks

Mike
0
 
JFTechAuthor Commented:
Thanks mkline71!
That fixed it!!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now