Created
May 11, 2015 20:00
-
-
Save robertchong/91ce6b47a124ca51ca86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'* Script name: List All Atributes.vbs | |
'* Created on: 01/28/2009 | |
'* Author: Andrew J Healey | |
'* Purpose: Exports all attributes from the user object type within | |
'* the Active Directory schema. | |
'* Schema: cscript /nologo "list all attribtues.vbs" > Attributes.csv | |
'* History: Andrew J Healey 01/28/2009 | |
'* - Created script | |
' | |
Option Explicit | |
'Declarations | |
Dim objUserClass : Set objUserClass = GetObject("LDAP://schema/user") | |
Dim objSchemaClass : Set objSchemaClass = GetObject(objUserClass.Parent) | |
wscript.echo chr(34) & "Mandatory" & chr(34) & "," & _ | |
chr(34) & "Name" & chr(34) & "," & _ | |
chr(34) & "Syntax" & chr(34) & "," & _ | |
chr(34) & "Single/Multi Valued" & chr(34) | |
Call GetAttributes(objUserClass.MandatoryProperties,objSchemaClass,True) | |
Call GetAttributes(objUserClass.OptionalProperties,objSchemaClass,False) | |
Private Sub GetAttributes(x,y,z) | |
Dim strAttribute | |
'Loop through all attributes | |
For Each strAttribute in x | |
Dim strOut : strOut = "" | |
'Compares whether the attribute is mandatory or optional | |
'Prints whether mandatory/optional and name of attribute | |
If z = True then | |
strOut = strOut & chr(34) & "Yes" & chr(34) & "," & _ | |
chr(34) & strAttribute & chr(34) & "," | |
Else | |
strOut = strOut & chr(34) & "No" & chr(34) & "," & _ | |
chr(34) & strAttribute & chr(34) & "," | |
End If | |
'Get the attributes syntax: i.e. Integer, String, NumericString, etc. | |
Dim objAttribute : Set objAttribute = y.GetObject("Property", strAttribute) | |
strOut = strOut & chr(34) & objAttribute.Syntax & chr(34) & "," | |
'Determines whether column holds multi or single values | |
If objAttribute.MultiValued Then | |
strOut = strOut & chr(34) & "Multi" & chr(34) | |
Else | |
strOut = strOut & chr(34) & "Single" & chr(34) | |
End If | |
'Print string to screen. Each line its own CSV. | |
wscript.echo strOut | |
strOut = Empty | |
Next | |
Set objAttribute = Nothing | |
strAttribute = Empty | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment