Account Lisitng

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there anyway to export ot an excel file a listing of all activer user
accounts and selected propertiesfrom active directory?
 
George said:
Is there anyway to export ot an excel file a listing of all activer user
accounts and selected propertiesfrom active directory?

Hi,

A sample VBScript program that exports the Distinguished Names of all users
to a spreadsheet is linked here:

http://www.rlmueller.net/Create User List 3.htm

To restrict this to active users, it depends on what you mean by active. To
include only users that are not disabled, replace this statement in the
program:

strFilter = "(&(objectCategory=person)(objectClass=user))"

with the following:

strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(!userAccountControl:1.2.840.113556.1.4.803:=2))"



To retrieve more attributes, add to the comma delimited list of attributes.
For example, replace:



strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName;subtree"

with:



strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName,sAMAccountName,cn,displayName;subtree"


Then, you in the loop that enumerates users, retrieve the new attribute
values with statements similar to the ones for Distinguished Name. Then
write the values to cells in new columns of the spreadsheet. For example,
replace:



Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
objSheet.Cells(k, 1).Value = strDN
k = k + 1
objRecordSet.MoveNext
Loop



With:



' Declare new variables.

Dim strNTName, strCN, strDisplayName



Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")

strNTName = objRecordset.Fields("sAMAccountName")

strCN = objRecordset.Fields("cn")

strDisplayName = objRecordset.Fields("displayName")
objSheet.Cells(k, 1).Value = strDN

objSheet.Cells(k, 2).Value = strNTName

objSheet.Cells(k, 3).Value = strCN

objSheet.Cells(k, 4).Value = strDisplayName
k = k + 1
objRecordSet.MoveNext
Loop


Also, note that any script or utility that outputs attribute values in a
comma delimited format can be used. Either specify an export file or
redirect the output to a text file. This file can be imported into a
spreadsheet. The utility csvde, for example, can export attribute values to
a comma delimited text file that can be imported into a spreadsheet. Get
help for csvde at the command prompt of a Domain Controller.
 
Hello,

Thanks for posting!

I suggeset you export the User Accounts from AD using LDIFDE. For more
detailed information please refer to the following article:

237677 Using LDIFDE to Import and Export Directory Objects to Active
Directory
http://support.microsoft.com/default.aspx?scid=kb;EN-US;237677

Hope the information helps.

Best Regards,

Jason Tan

Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

=====================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
| Thread-Topic: Account Lisitng
| thread-index: AcYcZXBofVIHyoMARVebBg8z5krBvw==
| X-WBNR-Posting-Host: 209.244.152.162
| From: "=?Utf-8?B?R2VvcmdlIFNjaG5laWRlcg==?="
<[email protected]>
| Subject: Account Lisitng
| Date: Wed, 18 Jan 2006 11:29:02 -0800
| Lines: 2
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.win2000.active_directory
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.win2000.active_directory:110925
| X-Tomcat-NG: microsoft.public.win2000.active_directory
|
| Is there anyway to export ot an excel file a listing of all activer user
| accounts and selected propertiesfrom active directory?
|
 
There's also the command line. Use the query provided by Richard's
excellent script with ADFIND (www.joeware.net) or DSQUERY (k3
%systemroot%\system32).

e.g. something like:

adfind -b dc=domain-name,dc=com -f
"(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
cn samaccountname givenname sn <etc.> -nodn -csv > filename.csv


Note. That is one line.
 
Back
Top