![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | requesting help: Looking to see if a local user exists. Im having a bit of trouble finding this. I have some AD samples to do the same, but I need to find out if a user exists locally. Basically: If User "Administrator" exists then call Subexists else call Subnoexist figure I would ask. TYIA - Ryan |
My System Specs![]() |
| | #2 (permalink) |
| | Re: requesting help: Looking to see if a local user exists. "Ryan" <djcalvin@xxxxxx> wrote in message news:ulUTw0RGJHA.1720@xxxxxx Quote: > Im having a bit of trouble finding this. I have some AD samples to do the > same, but I need to find out if a user exists locally. > > Basically: > If User "Administrator" exists then call Subexists > else call Subnoexist > > > figure I would ask. > TYIA accounts are, by definition, not AD accounts. You will need to use the WinNT provider. /Al |
My System Specs![]() |
| | #3 (permalink) |
| | Re: requesting help: Looking to see if a local user exists. "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:e$4%23GJUGJHA.3736@xxxxxx Quote: > > "Ryan" <djcalvin@xxxxxx> wrote in message > news:ulUTw0RGJHA.1720@xxxxxx Quote: >> Im having a bit of trouble finding this. I have some AD samples to do the >> same, but I need to find out if a user exists locally. >> >> Basically: >> If User "Administrator" exists then call Subexists >> else call Subnoexist >> >> >> figure I would ask. >> TYIA > If your "AD samples" use the LDAP provider, this will not work, as local > accounts are, by definition, not AD accounts. You will need to use the > WinNT provider. > > /Al > > WinNT provider and trap the possible error. In brief: strUser = "Administrator" strComputer = "TestComputer" On Error Resume Next Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user") If (Err.Number = 0) Then On Error GoTo 0 Wscript.Echo "Local user " & strUser & " exists." Else On Error GoTo 0 Wscript.Echo "Local user " & strUser & " does NOT exist." End If -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #4 (permalink) |
| | Re: requesting help: Looking to see if a local user exists. >> Richard Mueller [MVP] wrote Quote: Quote: >> >> > And one way to tell if a specific user exists is to attempt to bind with the > WinNT provider and trap the possible error. In brief: > > strUser = "Administrator" > strComputer = "TestComputer" > On Error Resume Next > Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user") > If (Err.Number = 0) Then > On Error GoTo 0 > Wscript.Echo "Local user " & strUser & " exists." > Else > On Error GoTo 0 > Wscript.Echo "Local user " & strUser & " does NOT exist." > End If > I thought there was a userexists call though? (I've been reading way too many vbs books late late at night, prob misread it) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| renaming Local user account and Changing "Full Name" of same Local | VB Script | |||
| Ethernet Multiple Networks detected, Local access only, Only one exists | Vista networking & sharing | |||
| Box requesting user name & password | Vista mail | |||
| local user | PowerShell | |||
| local user please | PowerShell | |||