Real Geek Forums  

Go Back   Real Geek Forums > Archives > Operating Systems > Windows XP > Windows XP WMI

Notices

Reply

Reporting Domain accounts on the local PC

 

LinkBack Thread Tools Display Modes
Old 01-05-2006, 03:18 PM   #1 (permalink)
Default Reporting Domain accounts on the local PC

Using the query below I can report all the local accounts on a PC.

Set cUsers = oWMIService.ExecQuery("Select * from Win32_UserAccount Where
LocalAccount = True")

Can I use WMI to report all the local accounts as well as all the domain
accounts and groups that are present on a PC?

Thanks,

Tom


Tom Ker
Guest
 
Posts: n/a
Reply With Quote  
Old 01-05-2006, 05:54 PM   #2 (permalink)
Default Re: Reporting Domain accounts on the local PC

Tom Ker wrote:
Quote:
> Using the query below I can report all the local accounts on a PC.
>
> Set cUsers = oWMIService.ExecQuery("Select * from Win32_UserAccount Where
> LocalAccount = True")
>
> Can I use WMI to report all the local accounts as well as all the domain
> accounts and groups that are present on a PC?
Hi,

There are no domain accounts or groups on the PC. However, domain users and
groups can be members of local groups. Also, when domain users logon can
leave a profile, so in a sense the PC "knows" about the domain user. Do you
want to know what domain users and groups are members of local groups?

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net


Richard Mueller
Guest
 
Posts: n/a
Reply With Quote  
Old 01-05-2006, 06:54 PM   #3 (permalink)
Default Re: Reporting Domain accounts on the local PC


"Tom Ker" <thomasDOTkerA@Thighmark.com> wrote in message
news:%23Xn$yOhEGHA.2856@TK2MSFTNGP12.phx.gbl...
Quote:
> Using the query below I can report all the local accounts on a PC.
>
> Set cUsers = oWMIService.ExecQuery("Select * from Win32_UserAccount Where
> LocalAccount = True")
>
> Can I use WMI to report all the local accounts as well as all the domain
> accounts and groups that are present on a PC?
>
> Thanks,
>
> Tom

The local PC will only have local accounts and local groups, it will never have
any domain accounts or domain groups (unless you run the script from a domain
controller).

Explain what you are trying to accomplish. Are you trying to enumerate group
members?

If you're trying to enumerate domain accounts, change the "Local Account = True"
portion of your query to "Local Account = False".



Marty List
Guest
 
Posts: n/a
Reply With Quote  
Old 01-05-2006, 08:26 PM   #4 (permalink)
Default Re: Reporting Domain accounts on the local PC

Thanks for the quick reply. See my longer reply to Richard for some
details.

I tried "LocalAccount = False" and got the results you stated - not what I'm
after, though.

Thanks,

Tom

"Marty List" <usenet@optimumx.com> wrote in message
news:%23Gi%23NHjEGHA.344@TK2MSFTNGP11.phx.gbl...
Quote:
>
>
> The local PC will only have local accounts and local groups, it will never
> have any domain accounts or domain groups (unless you run the script from
> a domain controller).
>
> Explain what you are trying to accomplish. Are you trying to enumerate
> group members?
>
> If you're trying to enumerate domain accounts, change the "Local Account =
> True" portion of your query to "Local Account = False".
>
>
>

Tom Ker
Guest
 
Posts: n/a
Reply With Quote  
Old 01-05-2006, 08:29 PM   #5 (permalink)
Default Re: Reporting Domain accounts on the local PC

Thanks for the quick reply. Guess I should have thought more about what I
was writing.

Yes, I am looking for all local users that have been created and all domain
users that have been added to local groups and any domain groups that have
been added to local groups. In this instance I do not care who has logged
on in the past, so I don't care what profiles have been created in the Docs
& Settings folder.

Since that short WMI query is cleaner and seems to process the local users
faster than looping with the code below, I thought I'd give WMI a try.
(Basically, I'm trying to expand my horizons with some new techniques.) The
code below is what I'm using today to create a dictionary of all objects in
all groups and all users that were created but not associated with any
group.

------ snip ------
Set cUsers = GetObject("WinNT://" & sCompName & "")
cUsers.Filter = Array("User")
Set cGroups = GetObject("WinNT://" & sCompName & "")
cGroups.Filter = Array("Group")
Set oUserDict = CreateObject("Scripting.Dictionary")

'Build User dictionary
sName = "xxxx" : sStatus = "xxxx"
For Each oGroup in cGroups
For Each oUser in oGroup.Members
Call Get_User
If NOT oUserDict.Exists(sName) Then
oUserDict.Add sName, sStatus & "," & LCase(oGroup.Name)
Else
sGrpList = oUserDict.Item(sName)
oUserDict.Remove(sName)
oUserDict.Add sName, sGrpList & "," & LCase(oGroup.Name)
End If
Next
Next
For Each oUser in cUsers
Call Get_User
If NOT oUserDict.Exists(sName) Then oUserDict.Add sName, sStatus &
",no_group"
Next

'Get and report the user's name and status
Sub Get_User()
sUser = Right(oUser.AdsPath, Len(oUser.AdsPath) - 8) 'Remove the
"WinNT://"
aUser = Split(sUser, "/")
If UBound(aUser) = 2 Then 'UBound = 2 for Local Users
sName = UCase(sCompName) & "\" & oUser.Name
bUserDisabled = CBool(oUser.AccountDisabled)
If bUserDisabled Then
sStatus = " -- Found Disabled"
Else
sStatus = " -- Found Active"
End If
Else 'Process other users or groups
If InStr(LCase(sUser), "domainname") <> 0 Then
sName = "DOMAINNAME\" & oUser.Name
sStatus = " -- Domain ID/Group"
Else
sName = "NT AUTHORITY\" & oUser.Name
sStatus = " -- System Generated"
End If
bUserDisabled = FALSE
End If
End Sub

------ snip ------

Thanks,
Tom

"Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in message
news:uzD7wliEGHA.3984@TK2MSFTNGP14.phx.gbl...
Quote:
> Tom Ker wrote:
>
Quote:
>> Using the query below I can report all the local accounts on a PC.
>>
>> Set cUsers = oWMIService.ExecQuery("Select * from Win32_UserAccount Where
>> LocalAccount = True")
>>
>> Can I use WMI to report all the local accounts as well as all the domain
>> accounts and groups that are present on a PC?
>
> Hi,
>
> There are no domain accounts or groups on the PC. However, domain users
> and groups can be members of local groups. Also, when domain users logon
> can leave a profile, so in a sense the PC "knows" about the domain user.
> Do you want to know what domain users and groups are members of local
> groups?
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>

Tom Ker
Guest
 
Posts: n/a
Reply With Quote  
Reply

Tags
None

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Enumerating local accounts with WMI Jay Worley Windows XP WMI 1 03-16-2005 05:56 AM
Converting profiles from local to domain.... msnews.microsoft.com Windows XP Configuration & Management 1 09-20-2004 05:29 PM
Does anyone know WHAT Local SYSTEM Accounts are (in WIN XP Pro), Vern Windows XP Configuration & Management 0 09-02-2004 07:30 AM
distinguish between local or domain account? Chris Sharp Windows XP WMI 2 06-21-2004 11:21 PM
Internet Authentication Service (IAS) server only supports local user accounts Oliver Windows XP Work Remotely 0 07-17-2003 08:54 AM


All times are GMT. The time now is 02:08 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2005 - 2007 RealGeek.com. All rights reserved.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90