Hallo Leute,
der Code dient dazu eine Datei zu erstellen in welcher man immer wieder nachgucken kann
welcher getter welche User infos holt.
Nichts besonderes und für die meisten auch nicht interessant, aber eine kleine Fleißaufgabe.
Hier Code:
Spoiler anzeigen
*Topic verschoben*
der Code dient dazu eine Datei zu erstellen in welcher man immer wieder nachgucken kann
welcher getter welche User infos holt.
Nichts besonderes und für die meisten auch nicht interessant, aber eine kleine Fleißaufgabe.
Hier Code:
Visual Basic-Quellcode
- Dim fso ' FileSystemObject
- Dim targetFile ' Path of Textfile containing Script Output
- Dim fileStream ' TextStream Object from fso Method OpenTextFile
- Dim sysInfo ' ADSystemInfo Object
- Dim adUser ' Logged in User
- ' Constants for the OpenTextFile Method of the FileSystemObject
- Const MODE_READ = 1 'Open for reading
- Const MODE_WRITE = 2 'Open for writing
- Const MODE_APPEND = 8 'Open to write to end of File
- Const FORMAT_ASCII = 0 'Opens file as ASCII (default)
- Const FORMAT_UNICODE = -1 'Opens file as Unicode
- Const FORMAT_SYSTEM_DEFAULT = -2 'Opens file with whatever is the system default
- On Error Resume Next
- ' Create Textfile to write in
- '==============================================================================================
- Set fso = CreateObject("Scripting.FileSystemObject")
- targetFile = fso.GetParentFolderName(WScript.ScriptFullName)
- targetFile = fso.BuildPath(targetFile, "ADUserInformations.txt")
- 'CreateTextFile(Filename, [Overwrite], [Unicode])
- fso.CreateTextFile targetFile, true
- If Err.Number <> 0 Then
- WScript.Echo "Could not create file (" & targetFile & ")."
- WScript.Quit
- End If
- ' Get currently Logged in User
- '==============================================================================================
- Set sysInfo = CreateObject("ADSystemInfo")
- Set adUser = GetObject("LDAP://" & sysInfo.UserName)
- If Err.Number <> 0 Then
- WScript.Echo "Could not get currently Logged in User"
- fso.DeleteFile targetFile
- WScript.Quit
- End if
- ' Get TextStream of created file
- '==============================================================================================
- 'OpenTextFile(Filename, [Mode], [Create], [Format])
- Set fileStream = fso.OpenTextFile(targetFile, _
- MODE_APPEND, _
- True, _
- FORMAT_ASCII)
- If Err.Number <> 0 Then
- WScript.Echo "Could not create TextStream for file: " & targetFile
- fso.DeleteFile targetFile
- WScript.Quit
- End If
- ' Write AD User information into file
- '==============================================================================================
- fileStream.WriteLine("Scroll down to RESULTS to see what the listed commands return")
- fileStream.WriteLine("")
- fileStream.WriteLine("How to get the adUser:")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("Dim sysInfo 'ADSystemInfo Object")
- fileStream.WriteLine("Dim adUser 'Currently Logged in User")
- fileStream.WriteLine("")
- fileStream.WriteLine("Set sysInfo = CreateObject(""ADSystemInfo"")")
- fileStream.WriteLine("Set adUser = GetObject(""LDAP://"" & sysInfo.UserName)")
- fileStream.WriteLine("")
- fileStream.WriteLine("")
- fileStream.WriteLine("")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("COMMAND OVERVIEW")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.distinguishedName")
- fileStream.WriteLine("")
- fileStream.WriteLine("GENERAL")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.givenName")
- fileStream.WriteLine("adUser.FirstName")
- fileStream.WriteLine("adUser.initials")
- fileStream.WriteLine("adUser.sn")
- fileStream.WriteLine("adUser.LastName")
- fileStream.WriteLine("adUser.displayName")
- fileStream.WriteLine("adUser.FullName")
- fileStream.WriteLine("adUser.description")
- fileStream.WriteLine("adUser.physicalDeliveryOfficeName")
- fileStream.WriteLine("adUser.telephoneNumber")
- fileStream.WriteLine("adUser.otherTelephone")
- fileStream.WriteLine("adUser.mail")
- fileStream.WriteLine("adUser.EmailAddress")
- fileStream.WriteLine("adUser.wWWHomePage")
- fileStream.WriteLine("adUser.url")
- fileStream.WriteLine("")
- fileStream.WriteLine("ADDRESS")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.streetAddress")
- fileStream.WriteLine("adUser.postOfficeBox")
- fileStream.WriteLine("adUser.l")
- fileStream.WriteLine("adUser.st")
- fileStream.WriteLine("adUser.postalCode")
- fileStream.WriteLine("adUser.countryCode")
- fileStream.WriteLine("adUser.c") '(ISO 4217)
- fileStream.WriteLine("")
- fileStream.WriteLine("ACCOUNT")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.userPrincipalName")
- fileStream.WriteLine("adUser.sAMAccountName")
- fileStream.WriteLine("adUser.AccountDisabled")
- fileStream.WriteLine("adUser.userAccountControl")
- fileStream.WriteLine("adUser.logonHours")
- fileStream.WriteLine("adUser.userWorkstations")
- fileStream.WriteLine("adUser.pwdLastSet")
- fileStream.WriteLine("adUser.userAccountControl")
- fileStream.WriteLine("adUser.userAccountControl")
- fileStream.WriteLine("adUser.userAccountControl")
- fileStream.WriteLine("adUser.accountExpires")
- fileStream.WriteLine("")
- fileStream.WriteLine("PROFILE")
- fileStream.WriteLine("adUser.profilePath")
- fileStream.WriteLine("adUser.Profile")
- fileStream.WriteLine("adUser.scriptPath")
- fileStream.WriteLine("adUser.homeDirectory")
- fileStream.WriteLine("adUser.homeDrive")
- fileStream.WriteLine("adUser.homeDirectory")
- fileStream.WriteLine("")
- fileStream.WriteLine("TELEPHONE")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.homePhone")
- fileStream.WriteLine("adUser.otherHomePhone")
- fileStream.WriteLine("adUser.pager")
- fileStream.WriteLine("adUser.otherPager")
- fileStream.WriteLine("adUser.mobile")
- fileStream.WriteLine("adUser.otherMobile")
- fileStream.WriteLine("adUser.facsimileTelephoneNumber")
- fileStream.WriteLine("adUser.otherFacsimileTelephoneNumber")
- fileStream.WriteLine("adUser.ipPhone")
- fileStream.WriteLine("adUser.otherIpPhone")
- fileStream.WriteLine("adUser.info")
- fileStream.WriteLine("")
- fileStream.WriteLine("ORGANISATION")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("adUser.title")
- fileStream.WriteLine("adUser.department")
- fileStream.WriteLine("adUser.company")
- fileStream.WriteLine("adUser.manager")
- fileStream.WriteLine("")
- fileStream.WriteLine("")
- fileStream.WriteLine("")
- fileStream.WriteLine("")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("RESULTS")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("")
- fileStream.WriteLine("Distinguished Name: " & adUser.distinguishedName)
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("")
- fileStream.WriteLine("GENERAL")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("First name: " & adUser.givenName)
- fileStream.WriteLine("First name: " & adUser.FirstName)
- fileStream.WriteLine("Initials: " & adUser.initials)
- fileStream.WriteLine("Last name: " & adUser.sn)
- fileStream.WriteLine("Last name: " & adUser.LastName)
- fileStream.WriteLine("Display name: " & adUser.displayName)
- fileStream.WriteLine("Display name: " & adUser.FullName)
- fileStream.WriteLine("Description: " & adUser.description)
- fileStream.WriteLine("Office: " & adUser.physicalDeliveryOfficeName)
- fileStream.WriteLine("Telephone number: " & adUser.telephoneNumber)
- fileStream.WriteLine("Other Telephone numbers: " & adUser.otherTelephone)
- fileStream.WriteLine("Email: " & adUser.mail)
- fileStream.WriteLine("Email: " & adUser.EmailAddress)
- fileStream.WriteLine("Web page: " & adUser.wWWHomePage)
- fileStream.WriteLine("Other Web pages: " & adUser.url)
- fileStream.WriteLine("")
- fileStream.WriteLine("ADDRESS")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("Street: " & adUser.streetAddress)
- fileStream.WriteLine("P.O. Box: " & adUser.postOfficeBox)
- fileStream.WriteLine("City: " & adUser.l)
- fileStream.WriteLine("State/province: " & adUser.st)
- fileStream.WriteLine("Zip/Postal Code: " & adUser.postalCode)
- fileStream.WriteLine("Country/region: " & adUser.countryCode)
- fileStream.WriteLine("Country/region: " & adUser.c) '(ISO 4217)
- fileStream.WriteLine("")
- fileStream.WriteLine("ACCOUNT")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("User logon name: " & adUser.userPrincipalName)
- fileStream.WriteLine("pre-Windows 2000 logon name: " & adUser.sAMAccountName)
- fileStream.WriteLine("AccountDisabled: " & adUser.AccountDisabled)
- fileStream.WriteLine("Account Control #: " & adUser.userAccountControl)
- fileStream.WriteLine("Logon Hours: " & adUser.logonHours)
- fileStream.WriteLine("Logon On To (Logon Workstations): " & adUser.userWorkstations)
- fileStream.WriteLine("User must change password at next logon: " & adUser.pwdLastSet)
- fileStream.WriteLine("User cannot change password: " & adUser.userAccountControl)
- fileStream.WriteLine("Password never expires: " & adUser.userAccountControl)
- fileStream.WriteLine("Store password using reversible encryption: " & adUser.userAccountControl)
- fileStream.WriteLine("Account expires end of (date): " & adUser.accountExpires)
- fileStream.WriteLine("")
- fileStream.WriteLine("PROFILE")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("Profile path: " & adUser.profilePath)
- fileStream.WriteLine("Profile path: " & adUser.Profile)
- fileStream.WriteLine("Logon script: " & adUser.scriptPath)
- fileStream.WriteLine("Home folder, local path: " & adUser.homeDirectory)
- fileStream.WriteLine("Home folder, Connect, Drive: " & adUser.homeDrive)
- fileStream.WriteLine("Home folder, Connect, To:: " & adUser.homeDirectory)
- fileStream.WriteLine("")
- fileStream.WriteLine("TELEPHONE")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("Home: " & adUser.homePhone)
- fileStream.WriteLine("Other Home phone numbers: " & adUser.otherHomePhone)
- fileStream.WriteLine("Pager: " & adUser.pager)
- fileStream.WriteLine("Other Pager numbers: " & adUser.otherPager)
- fileStream.WriteLine("Mobile: " & adUser.mobile)
- fileStream.WriteLine("Other Mobile numbers: " & adUser.otherMobile)
- fileStream.WriteLine("Fax: " & adUser.facsimileTelephoneNumber)
- fileStream.WriteLine("Other Fax numbers: " & adUser.otherFacsimileTelephoneNumber)
- fileStream.WriteLine("IP phone: " & adUser.ipPhone)
- fileStream.WriteLine("Other IP phone numbers: " & adUser.otherIpPhone)
- fileStream.WriteLine("Notes: " & adUser.info)
- fileStream.WriteLine("")
- fileStream.WriteLine("ORGANISATION")
- fileStream.WriteLine("================================================")
- fileStream.WriteLine("Title: " & adUser.title)
- fileStream.WriteLine("Department: " & adUser.department)
- fileStream.WriteLine("Company: " & adUser.company)
- fileStream.WriteLine("Manager: " & adUser.manager)
- fileStream.Close
- '==============================================================================================
- ' END OF CODE
- '==============================================================================================
*Topic verschoben*
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()