DOC PREVIEW
DMC ITSY 2430 - WINDOWS SERVER HACKS

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

TMMitch Tulloch100 Industrial-Strength Tips & ToolsWIN DO WSSERVERHACKSPresented by:Get User Account Information #28Chapter 3, User Management|95HACKHACK#28Get User Account Information Hack #28Need to find information about user accounts on a machine? Use this handyscript to do it fast.This script lets you quickly query a Windows 2000 (or later) machine todetermine what user accounts are present, whether local accounts in theSAM database or domain accounts in Active Directory. It will output a list ofaccounts, giving the following information for each account:• Username of user• Full name of user• Account lockout status• Whether the user is allowed to change the password• Whether the account is nonexpiring or notThe CodeTo use the script, simply type it into Notepad (with Word Wrap turned off)and save it with a .vbs extension as GetAccountInfo.vbs:ComputerName = localhostwinmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""Set UserSet = GetObject( winmgmt1 ).InstancesOf ("Win32_UserAccount")for each User in UserSetWScript.Echo "==============================================="WScript.Echo "Information for " & User.NameWScript.Echo "The full username for the specified computer is: " & _User.FullNameWScript.Echo "Account Locked? " & User.LockoutWScript.Echo "Password can be changed?: " & User.PasswordChangeableWScript.Echo "Password is expirable: " & User.PasswordExpiresWScript.Echo "==============================================="NextRunning the HackHere’s some typical output when the script is run locally on a Windows2000 domain controller. To avoid getting the series of dialog boxes thatwould appear if you ran the script using Wscript.exe, use Cscript.exe to run itfrom the command-line instead:C:\>cscript.exe C:\MyScripts\GetAccountInfo.vbsMicrosoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.96|Chapter 3, User Management#28 Get User Account InformationHACK===============================================Information for AdministratorThe full username for the specified computer is:Account Locked? FalsePassword can be changed?: TruePassword is expirable: False==============================================================================================Information for GuestThe full username for the specified computer is:Account Locked? FalsePassword can be changed?: FalsePassword is expirable: False==============================================================================================Information for jsmithThe full username for the specified computer is: Jane SmithAccount Locked? FalsePassword can be changed?: TruePassword is expirable: False==============================================================================================Information for bsmithThe full username for the specified computer is: Bob SmithAccount Locked? FalsePassword can be changed?: TruePassword is expirable: True===============================================The output continues for the remaining accounts on the system.Hacking the HackYou can easily modify the script to get user information from a remote com-puter instead of from the local computer on which the script is running.This is useful when you want to run the script from an administrator work-station instead of interactively on a domain controller.Simply change this line:ComputerName = localhostto this:ComputerName = InputBox("Enter the name of the computer you wish to query")The script will prompt you with a dialog box (see Figure 3-3) for the nameof the remote computer whose accounts you want to query. You can specifythe NetBIOS name, DNS name, or IP address of the remote machine, as longas your currently logged-on account has administrative privileges on theremote machine.Get User Account Information #28Chapter 3, User Management|97HACK—Rod TrentFigure 3-3. Querying user account information on a remote computerThis material has been adapted from Windows Server Hacks by Mitch Tulloch, published by O'Reilly Media, Inc. Copyright O'Reilly Media, Inc., 2004. All rights reserved. To purchase this or other O'Reilly publications, click


View Full Document

DMC ITSY 2430 - WINDOWS SERVER HACKS

Documents in this Course
Load more
Download WINDOWS SERVER HACKS
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view WINDOWS SERVER HACKS and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view WINDOWS SERVER HACKS 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?