PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > Export list of users in each OU
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Export list of users in each OU

Réponse
 
LinkBack Outils de la discussion
Vieux 19/09/2007, 00h08   #1 (permalink)
TJCooper1972
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Export list of users in each OU

Can someone please point me to a script that creates an spreadsheet that list
OUs and accounts in each container. For example:

Accounts
SC
Tim
Tom
Tammy

Perhaps a workboot for each container under accounts. If someone can point
me to something close, I can usually modify it.

Thank you

coopert
  Réponse avec citation
Vieux 19/09/2007, 00h48   #2 (permalink)
Al Dunbar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Export list of users in each OU

Have a look here:

http://www.rlmueller.net/DocumentUsers.htm

/Al

"TJCooper1972" <TJCooper1972@discussions.microsoft.com> wrote in message
news:3B5F55AF-8960-4A37-8B10-32CA2A2026F9@microsoft.com...
> Can someone please point me to a script that creates an spreadsheet that
> list
> OUs and accounts in each container. For example:
>
> Accounts
> SC
> Tim
> Tom
> Tammy
>
> Perhaps a workboot for each container under accounts. If someone can point
> me to something close, I can usually modify it.
>
> Thank you
>
> coopert



  Réponse avec citation
Vieux 19/09/2007, 01h12   #3 (permalink)
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Export list of users in each OU

TJCooper1972 wrote:

> Can someone please point me to a script that creates an spreadsheet that
> list
> OUs and accounts in each container. For example:
>
> Accounts
> SC
> Tim
> Tom
> Tammy
>
> Perhaps a workboot for each container under accounts. If someone can point
> me to something close, I can usually modify it.


The first step is to enumerate all containers (domains, OU's, and container
objects). You can either use ADO or code a recursive method. In either case
you enumerate objects with class "container", "organizationalUnit", or
"builtinDomain". Next you bind to each container object, filter on objects
of class user, and enumerate. For example (not tested):
==============
Option Explicit
Dim objRootDSE, strForest, objForest

Set objRootDSE = GetObject("LDAP://RootDSE")
strForest = objRootDSE.Get("rootDomainNamingContext")
Set objForest = GetObject("LDAP://" & strForest)

Call EnumDomains(objForest)

Sub EnumDomains(ByVal objParent)
' Recursive subroutine to enumerate users in domains.
Dim objUser, objContainer, objChild

' Enumerate users in domain.
objParent.Filter = Array("user")
For Each objUser In objParent
Wscript.Echo objParent.distinguishedName & ";" &
objUser.sAMAccountName
Next

' Enumerate containers in domain.
objParent.Filter = Array("container", "organizationalUnit",
"builtinDomain")
For Each objContainer In objParent
Call EnumContainers(objContainer)
Next

' Enumerate child domains.
objParent.Filter = Array("domain")
For Each objChild In objParent
Call EnumDomains(objChild)
Next

End Sub

Sub EnumContainers(ByVal objParent)
' Recursive subroutine to enumerate users in containers.
Dim objUser, objChild

' Enumerate users in container.
objParent.Filter = Array("user")
For Each objUser In objParent
Wscript.Echo objParent.distinguishedName & ";" &
objUser.sAMAccountName
Next

' Enumerate child containers.
objParent.Filter = Array("container", "organizationalUnit",
"builtinDomain")
For Each objChild In objParent
Call EnumContainers(objChild)
Next

End Sub
============
The script should be run at a command prompt with the cscript host. The
output can be redirected to a text file. The text file can be imported into
a spreadsheet program. The fields are semicolon delimited. The above
documents the distinguishedNames (DN's) of the domains, containers, and OU's
(the only way to uniquely identify them) and the NT names (pre-Windows 2000
logon names) of the users. You could document the distinguishedNames of
users instead. Or, since the DN of the parent container is in the first
column, you could even use the value of the cn attribute (Common Name).

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Vieux 19/09/2007, 16h30   #4 (permalink)
TJCooper1972
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Export list of users in each OU

I dont want to do the entire domain, but a specific container. I will see if
I can modify the script.

Thank you very much. I hope Microsoft is paying you for all the you
give on these forums. Or at least gives you some free software.

"Richard Mueller [MVP]" wrote:

> TJCooper1972 wrote:
>
> > Can someone please point me to a script that creates an spreadsheet that
> > list
> > OUs and accounts in each container. For example:
> >
> > Accounts
> > SC
> > Tim
> > Tom
> > Tammy
> >
> > Perhaps a workboot for each container under accounts. If someone can point
> > me to something close, I can usually modify it.

>
> The first step is to enumerate all containers (domains, OU's, and container
> objects). You can either use ADO or code a recursive method. In either case
> you enumerate objects with class "container", "organizationalUnit", or
> "builtinDomain". Next you bind to each container object, filter on objects
> of class user, and enumerate. For example (not tested):
> ==============
> Option Explicit
> Dim objRootDSE, strForest, objForest
>
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strForest = objRootDSE.Get("rootDomainNamingContext")
> Set objForest = GetObject("LDAP://" & strForest)
>
> Call EnumDomains(objForest)
>
> Sub EnumDomains(ByVal objParent)
> ' Recursive subroutine to enumerate users in domains.
> Dim objUser, objContainer, objChild
>
> ' Enumerate users in domain.
> objParent.Filter = Array("user")
> For Each objUser In objParent
> Wscript.Echo objParent.distinguishedName & ";" &
> objUser.sAMAccountName
> Next
>
> ' Enumerate containers in domain.
> objParent.Filter = Array("container", "organizationalUnit",
> "builtinDomain")
> For Each objContainer In objParent
> Call EnumContainers(objContainer)
> Next
>
> ' Enumerate child domains.
> objParent.Filter = Array("domain")
> For Each objChild In objParent
> Call EnumDomains(objChild)
> Next
>
> End Sub
>
> Sub EnumContainers(ByVal objParent)
> ' Recursive subroutine to enumerate users in containers.
> Dim objUser, objChild
>
> ' Enumerate users in container.
> objParent.Filter = Array("user")
> For Each objUser In objParent
> Wscript.Echo objParent.distinguishedName & ";" &
> objUser.sAMAccountName
> Next
>
> ' Enumerate child containers.
> objParent.Filter = Array("container", "organizationalUnit",
> "builtinDomain")
> For Each objChild In objParent
> Call EnumContainers(objChild)
> Next
>
> End Sub
> ============
> The script should be run at a command prompt with the cscript host. The
> output can be redirected to a text file. The text file can be imported into
> a spreadsheet program. The fields are semicolon delimited. The above
> documents the distinguishedNames (DN's) of the domains, containers, and OU's
> (the only way to uniquely identify them) and the NT names (pre-Windows 2000
> logon names) of the users. You could document the distinguishedNames of
> users instead. Or, since the DN of the parent container is in the first
> column, you could even use the value of the cn attribute (Common Name).
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h45.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11354 seconds with 12 queries