Is er een mogelijkheid om van alle users die in de active directory staan een lijst te exporteren met daarbij ook van welke groepen ze lid zijn?
Het gaat om server 2003
Het gaat om server 2003
VBScript gevonden op internet (doet niet de geneste groepen)lvnielen schreef op woensdag 22 oktober 2008 @ 21:28:
Is er een mogelijkheid om van alle users die in de active directory staan een lijst te exporteren met daarbij ook van welke groepen ze lid zijn?
Het gaat om server 2003
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
| ' DocumentGroups.vbs
' VBScript program to document all groups in Active Directory.
' Outputs group name, type of group, all members, and types of member.
' Lists all groups that are members, but does not list the nested group
' membership.
'
' ----------------------------------------------------------------------
' Copyright (c) 2002 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - November 10, 2002
' Version 1.1 - February 19, 2003 - Standardize Hungarian notation.
' Version 1.2 - March 11, 2003 - Remove SearchScope property.
' Version 1.3 - July 6, 2007 - Modify use of Fields collection of
' Recordset object.
' Version 1.4 - July 27, 2007 - Bug fix if group name has "/" character.
'
' This script is designed to be run at a command prompt, using the
' Cscript host. The output can be redirected to a text file.
' For example:
' cscript //nologo DocumentGroups.vbs > groups.txt
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty, obligations,
' or liability for such use.
Option Explicit
Dim adoConnection, adoCommand, objRootDSE, strDNSDomain, strQuery
Dim adoRecordset, strDN, objGroup
' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connection")
Set adoCommand = CreateObject("ADODB.Command")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Search for all groups, return the Distinguished Name of each.
strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectClass=group);distinguishedName;subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
Wscript.Echo "No groups found"
adoRecordset.Close
adoConnection.Close
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
Wscript.Quit
End If
' Enumerate all groups, bind to each, and document group members.
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("distinguishedName").Value
' Escape any forward slash characters with backslash.
strDN = Replace(strDN, "/", "\/")
Set objGroup = GetObject("LDAP://" & strDN)
Wscript.Echo objGroup.sAMAccountName _
& " (" & GetType(objGroup.groupType) & ")"
Call GetMembers(objGroup)
adoRecordset.MoveNext
Loop
adoRecordset.Close
' Clean up.
adoConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
Function GetType(ByVal intType)
' Function to determine group type from the GroupType attribute.
If ((intType And &h01) <> 0) Then
GetType = "Built-in"
ElseIf ((intType And &h02) <> 0) Then
GetType = "Global"
ElseIf ((intType And &h04) <> 0) Then
GetType = "Local"
ElseIf ((intType And &h08) <> 0) Then
GetType = "Universal"
End If
If ((intType And &h80000000) <> 0) Then
GetType = GetType & "/Security"
Else
GetType = GetType & "/Distribution"
End If
End Function
Sub GetMembers(ByVal objADObject)
' Subroutine to document group membership.
' Members can be users or groups.
Dim objMember, strType
For Each objMember In objADObject.Members
If (UCase(Left(objMember.objectCategory, 8)) = "CN=GROUP") Then
strType = "Group"
Else
strType = "User"
End If
Wscript.Echo " Member: " & objMember.sAMAccountName _
& " (" & strType & ")"
Next
Set objMember = Nothing
End Sub |
'Multiple exclamation marks,' he went on, shaking his head, 'are a sure sign of a diseased mind' (Terry Pratchett, Eric)
ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device
Lezen...lvnielen schreef op woensdag 22 oktober 2008 @ 23:53:
ik kan me vergissen maar als ik dit script laat lopen krijg ik alleen wat pop-up's inbeeld en verder zie ik niet dat hij wat exporteerd? Of mij is de locatie niet bekend?
cscript //nologo DocumentGroups.vbs > groups.txt
[ Voor 16% gewijzigd door Turdie op 23-10-2008 06:06 ]
lvnielen schreef op donderdag 23 oktober 2008 @ 00:18:
Ik heb ondertussen al wat in een txt gekregen.
Deze link werkt niet.alt-92 schreef op donderdag 23 oktober 2008 @ 01:09:
bouw zelf een script wat doet wat jij wil.
Voorbeelden genoeg te vinden op http://technet.microsoft.com/scriptcenter/ .
[ Voor 16% gewijzigd door lvnielen op 23-10-2008 08:46 ]
Dit topic is gesloten.
![]()
Apple iPhone 17 LG OLED evo G5 Google Pixel 10 Samsung Galaxy S25 Star Wars: Outlaws Nintendo Switch 2 Apple AirPods Pro (2e generatie) Sony PlayStation 5 Pro
Tweakers is onderdeel van
DPG Media B.V.
Alle rechten voorbehouden - Auteursrecht © 1998 - 2026
•
Hosting door TrueFullstaq