NinjaGeek Posted September 18, 2010 Share Posted September 18, 2010 I'm a dabbler when it comes to DLL or COM calls, so I'm not entirely sure how to implement this. I'm trying to use the DirectoryEntry.Exists method to check to see if a username exists on the domain, but I'm not sure where to even start. The method I'm referring to can be found here: http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.exists.aspxThanks in advance! Link to comment Share on other sites More sharing options...
wakillon Posted September 18, 2010 Share Posted September 18, 2010 I'm a dabbler when it comes to DLL or COM calls, so I'm not entirely sure how to implement this. I'm trying to use the DirectoryEntry.Exists method to check to see if a username exists on the domain, but I'm not sure where to even start. The method I'm referring to can be found here: http://msdn.microsoft.com/en-us/library/...ctoryservices.directoryentry.exists.aspx Thanks in advance! Alternatively you can get Domain's Users like this with this Jarvis script : expandcollapse popup#include <Array.au3> Global $Users $_ComputerUsers = _ComputerGetUsers($Users) _ArrayDisplay ( $_ComputerUsers ) For $i = 1 To $Users[0][0] Step 1 MsgBox(0, "Test _ComputerGetUsers", "Name: " & $Users[$i][0] & @CRLF & _ "Domain: " & $Users[$i][1] & @CRLF & _ "Status: " & $Users[$i][2] & @CRLF & _ "Local Account: " & $Users[$i][3] & @CRLF & _ "SID: " & $Users[$i][4] & @CRLF & _ "SIDType: " & $Users[$i][5] & @CRLF & _ "Description: " & $Users[$i][6] & @CRLF & _ "Full Name: " & $Users[$i][7] & @CRLF & _ "Disabled: " & $Users[$i][8] & @CRLF & _ "Lockout: " & $Users[$i][9] & @CRLF & _ "Password Changeable: " & $Users[$i][10] & @CRLF & _ "Password Expires: " & $Users[$i][11] & @CRLF & _ "Password Required: " & $Users[$i][12] & @CRLF & _ "Account Type: " & $Users[$i][13]) Next ;=============================================================================== ; Description: Returns the Users and information in an array. ; Parameter(s): $aUserInfo - By Reference - User Name and Information array. ; Requirement(s): None ; Return Value(s): On Success - Returns array of User Information. ; $aUserInfo[0][0] = Number of Users ; $aUserInfo[$i][0] = Name ($i starts at 1) ; $aUserInfo[$i][1] = Doamin ; $aUserInfo[$i][2] = Status ; $aUserInfo[$i][3] = Local Account ; $aUserInfo[$i][4] = SID ; $aUserInfo[$i][5] = SIDType ; $aUserInfo[$i][6] = Description ; $aUserInfo[$i][7] = Full Name ; $aUserInfo[$i][8] = Disabled ; $aUserInfo[$i][9] = Lockout ; $aUserInfo[$i][10] = Password Changeable ; $aUserInfo[$i][11] = Password Expires ; $aUserInfo[$i][12] = Password Required ; $aUserInfo[$i][13] = Account Type ; On Failure - @error = 1 and Returns 0 ; @extended = 1 - Array contains no information ; 2 - $colItems isnt an object ; Author(s): Jarvis Stubblefield (support "at" vortexrevolutions "dot" com) ; Note(s): ;=============================================================================== Func _ComputerGetUsers(ByRef $aUserInfo) Local $cI_Compname = @ComputerName, $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems, $objWMIService, $objItem Dim $aUserInfo[1][14], $i = 1 $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ReDim $aUserInfo[UBound($aUserInfo) + 1][14] $aUserInfo[$i][0] = $objItem.Name $aUserInfo[$i][1] = $objItem.Domain $aUserInfo[$i][2] = $objItem.Status $aUserInfo[$i][3] = $objItem.LocalAccount $aUserInfo[$i][4] = $objItem.SID $aUserInfo[$i][5] = $objItem.SIDType $aUserInfo[$i][6] = $objItem.Description $aUserInfo[$i][7] = $objItem.FullName $aUserInfo[$i][8] = $objItem.Disabled $aUserInfo[$i][9] = $objItem.Lockout $aUserInfo[$i][10] = $objItem.PasswordChangeable $aUserInfo[$i][11] = $objItem.PasswordExpires $aUserInfo[$i][12] = $objItem.PasswordRequired $aUserInfo[$i][13] = $objItem.AccountType $i += 1 Next $aUserInfo[0][0] = UBound($aUserInfo) - 1 If $aUserInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf EndFunc ;_ComputerGetUsers AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
water Posted September 18, 2010 Share Posted September 18, 2010 Or you could use my Active Directory UDF to check for existance of the user. For download please see my signature. A very basic example (without error checking) would look like: #include <ad.au3> _AD_Open() If _AD_ObjectExists(@Username) Then ... _AD_Close() My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now