Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using ACTIVE DIRECTORY how can I print out a list of all Users and their UserNames?

Posted on 2006-11-29
13
Medium Priority
?
284 Views
Last Modified: 2011-09-20
I have close to 400 users in AD and I don't want to have to look at them one at a time!   If I could get a list of just the UserNames I'd be in extacy!
0
Comment
Question by:JayMulkey
[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
13 Comments
 
LVL 2

Accepted Solution

by:
eric_bender earned 200 total points
ID: 18042200
You can use vbscripting and write an LDAP query or you can pipe the dsquery/dsget to a file.

Let me see if I can find one.  

Do you need to iterate through differ OU's or are they all in the same place.?
0
 

Author Comment

by:JayMulkey
ID: 18042352
Eric

I'm not as AD-savvy as you (did not understand much of what you said).
I will need to iterate through different OU's.

Thanks for your help.  This could save me a TON of time!

Jay
0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18042355

I use this script to give me a list of all the users & groups that exist beneath the OU in question.
As I commented this particular one writes the Group and Members (users) to a text file and each group is on one line, comma separated.
With a little modification. (do you script)  You can  tweak this one.  If not I can genericize it later.


Dim objBaseOU
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\touche.txt")

Set objBaseOU = GetObject("LDAP://OU=Touche Distribution Groups,DC=CU1,DC=ORG")

ProcessOU objBaseOU

Sub ProcessOU (ByRef objOU)
  Dim objUser, objGroup, objChildOU

  objOU.Filter = Array("user")
  WScript.Echo "Users in OU '" & objOU.Get("distinguishedName") & "':"
  For Each objUser In objOU
    WScript.Echo "  " & objUser.Get("distinguishedName")
  Next

For Each strName in arrNames
    objFile.write strpad + ","


  objOU.Filter = Array("group")
  WScript.Echo "Groups in OU '" & objOU.Get("distinguishedName") & "':"

  For Each objGroup In objOU
    WScript.Echo "  Members of group '" & objGroup.Get("distinguishedName") & "':"
    ProcessGroup objGroup, "    "
  Next

  objOU.Filter = Array("organizationalUnit")
  For Each objChildOU In objOU

    ProcessOU objChildOU
  Next
End Sub

Sub ProcessGroup (ByRef objGroup, ByVal strPad)
  Dim objMember

  For Each objMember In objGroup.Members
    If (LCase(objMember.Class) = "group") Then
      WScript.Echo strPad & objMember.Get("distinguishedName") & " (nested group)"
      ProcessGroup objMember, strPad & "  "
    Else
      WScript.Echo strPad & objMember.Get("distinguishedName")
    End If
  Next
End Sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:eric_bender
ID: 18042361
This does give you duplication though.  Let me work on just Iterating and sorting by OU.....
0
 
LVL 77

Assisted Solution

by:Rob Williams
Rob Williams earned 300 total points
ID: 18042386
There is a free little tool called DumpSec that will allow you to simply create reports with user account information. You can specify the information you want in the report such as user name, logon name, last time account was used, password expiries, permissions etc. These reports can be generated in different formats and can be exported as text files to import to Excel and other applications. You might want to have a look at it.
http://www.somarsoft.com/
0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18042396
Ok,

So copy the script below into notepad.
You should then just need to change the entry for Set objFile to represent your text file, replace c:\touche.txt   with your location... the file does not need to exist it will be created.  
Secondly change the OU Entry (mine being Touche Distribution Groups) to the OU entry you need to use.  Then change the DC to be your domain... i.e. cu1.org relates as below.

If you have any questions let me know.


Dim objBaseOU
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\touche.txt")

Set objBaseOU = GetObject("LDAP://OU=Touche Distribution Groups,DC=CU1,DC=ORG")

ProcessOU objBaseOU

Sub ProcessOU (ByRef objOU)
  Dim objUser, objGroup, objChildOU

  objOU.Filter = Array("user")
 
  For Each objUser In objOU
      objFile.writeblanklines 1
    objFile.write " A " & objUser.Get("name")
   
  Next


  objOU.Filter = Array("group")
 

  For Each objGroup In objOU
 objFile.writeblanklines 1
    objFile.write objGroup.Get("name") + ","
   
    ProcessGroup objGroup, "    "
  Next

  objOU.Filter = Array("organizationalUnit")
  For Each objChildOU In objOU

    ProcessOU objChildOU
  Next
End Sub

Sub ProcessGroup (ByRef objGroup, ByVal strPad)
  Dim objMember

  For Each objMember In objGroup.Members
    If (LCase(objMember.Class) = "group") Then
      objFile.write strPad & objMember.Get("Name") + ","
      
    Else
      objFile.write strPad & objMember.Get("Name") + ","
      
    End If
  Next
End Sub

0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18042411
Once you have made the changes save the document and rename the suffix as a .vbs  instead of the default of .txt

Then you can just double click on the it and after a short time your file will be created.

All this does is using LDAP (Lightweight Directory Addressing Protocol--AD) to retrieve the arguments accordingly.

Make sure the drive/folder exists and that you have changed the OU and Domain.  You can add additional OU= entries if you have and wish to test on a downlevel nested OU.

If you want to make the change and post it I can look at it before you run it.
0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18042415
I had tried that utility in the past Rob, and for what I was trying to do it wasn't useful, but it may give Jay what he needs.
0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18042428
I seem to recall that it wouldn't define the users through the nested groups.  It's been a while... I use the originally posted script to export to Excel and the post as an HTM on our Intranet for Distribution Group purposes.  
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 18046566
net user /domain > userlist.txt

or, for full names,

dsquery user "dc=yourdomain,dc=com" -name * -limit 0 | dsget user -display > userlist.txt
0
 
LVL 10

Expert Comment

by:MATTHEW_L
ID: 18053840
Shift-3 much better and easier solution.  net user /domain is the absolute easiest, but doesnt give all the info you wanted.  Also if you are using Win2003 create a saved query and export the list to excel.
0
 
LVL 2

Expert Comment

by:eric_bender
ID: 18054535
Thanx Let me know if you need any more help with the scripting.
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 18054996
Thanks JayMulkey. Good luck with it,
--Rob
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

This article is in response to a question (http://www.experts-exchange.com/Networking/Network_Management/Network_Analysis/Q_28230497.html) here at Experts Exchange. The Original Poster (OP) requires a utility that will accept a list of IP addresses …
We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

722 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