Page 1 of 2 12>
Topic Options
#113841 - 2004-02-11 10:02 PM Local Admin Members
JohnQ Offline
Starting to like KiXtart

Registered: 2003-03-04
Posts: 171
Does anyone know of a way to enumerate the members of the local admin group on a NT4 workstation (No ADSI)?

Looking for a method other than Howard's dll.

Top
#113842 - 2004-02-11 10:08 PM Re: Local Admin Members
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Does this work on nt: "net localgroup administrators" (from command prompt)
_________________________
Eric

Top
#113843 - 2004-02-11 10:15 PM Re: Local Admin Members
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can use GrpMaint.exe as a standalone solution. You can enum remote servers and workstations. Or are you looking for a way to do this from within the logon script as a user?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113844 - 2004-02-11 10:31 PM Re: Local Admin Members
JohnQ Offline
Starting to like KiXtart

Registered: 2003-03-04
Posts: 171
Howard, I would like to run it from the login script. Users will have admin rights.

Shelling out net localgroup administrators would be a possible solution, but it doesn't differentiate between users and groups as members. It just spits out everything.

Top
#113845 - 2004-02-11 10:40 PM Re: Local Admin Members
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, why you want to have loginscript checking for all admin group members?
_________________________
!

download KiXnet

Top
#113846 - 2004-02-11 10:44 PM Re: Local Admin Members
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I can not understand the requirement for a user to enum the group. Can you tell us what exactly you want to get from this operation and how you intend to use the data?
Code:
break On
? @kix
? ingroup("\\@wksta\administrators")

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113847 - 2004-02-11 11:00 PM Re: Local Admin Members
JohnQ Offline
Starting to like KiXtart

Registered: 2003-03-04
Posts: 171
The information will be gathered as part of our invnetory script at login. This info is of no value to the user and the user never sees it, but the info is stored in a SQL database. This allows us to audit the members of the local admin group on any given PC. Many PC's have members who should not be.
Top
#113848 - 2004-02-11 11:45 PM Re: Local Admin Members
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
This code should work to get all of the objects that are in the local admin group. I dont know how to tell the difference from users and groups however.

Code:
$memberfile = "%temp%\adminmembers.tmp"
If Exist ($memberfile)
Del $memberfile
Endif
Shell '%comspec% /c net localgroup administrators > '+$memberfile
$members = ArrayEnumText($memberfile)
Del $memberfile

For Each $member in $members
? $member
Next

get $

FUNCTION ArrayEnumText($TextFile)
Dim $TextHandle,$Line,$LineArray,$LineValue
$TextHandle = FreeFileHandle()
If Open ($TextHandle,$TextFile) = 0
While @Error = 0 and $trigger < 1
$Line = ReadLine ($TextHandle)
If InStr ($line, "---")
$trigger = 1
Endif
Loop
$LineValue = 0
While @Error = 0
$Line = ReadLine ($TextHandle)
If Not InStr ($line, "The command completed successfully")
ReDim Preserve $ArrayEnumText[$LineValue]
$ArrayEnumText[$LineValue] = $Line
$LineValue = $LineValue+1
Endif
Loop
$null = Close ($TextHandle)
If UBound ($ArrayEnumText) >= 0
Exit 0
Else
Exit 1
Endif
Else
Exit 1
Endif
ENDFUNCTION


Top
#113849 - 2004-02-12 12:07 AM Re: Local Admin Members
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, this worked on my w2k system:
Code:

"listing local admin group accounts:" ?
$bk="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy"
$sk=enumkey($bk,$)
do
$count=0+readvalue($bk+"\"+$sk+"\GroupMembership","count")
if $count
for $2=1 to $count
if "S-1-5-32-544"=readvalue($bk+"\"+$sk+"\GroupMembership","Group"+$2)
$un=sidtoname($sk)
if len($un)
$un ?
endif
endif
next
endif
$=$+1
$sk=enumkey($bk,$)
until @error
get $

_________________________
!

download KiXnet

Top
#113850 - 2004-02-12 01:32 AM Re: Local Admin Members
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Nice...It also works on XP Pro
Top
#113851 - 2004-02-12 01:34 AM Re: Local Admin Members
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn.
I have mistakenly created script that has potential to become UDF
_________________________
!

download KiXnet

Top
#113852 - 2004-02-12 01:44 AM Re: Local Admin Members
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Yes, good code for 2000/XP there Lonk

However for NT 4 which was the original request it does not appear to work. I tested it on NT 4 SP6a workstation and NT 4 Server SP6a and neither one returned info.


So unless Lonk or someone else can figure out a pure KiXtart method, I'll suggest this.


NetLocalGroupEnum
NetUserGetLocalGroups
NetUserEnum


Using Win32 C,C++,VB,Perl,Python,etc... you could use

NetLocalGroupGetMembers

Otherwise you may have to locate a compiled .EXE or use WSH/ADSI to really accomplish this task.

Here is a tool that I think should do what you're looking to do, but I've not tested it on NT 4
http://www.joeware.net/win32/zips/Lg.zip

He also has a lot of other nice utilities for Admin work.

http://www.joeware.net/

Top
#113853 - 2004-02-12 01:48 AM Re: Local Admin Members
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Also, on 2000/XP it will show my own account which is a member of a Universal group on the AD, but it won't list the members of the other users in that group which actually do have local admin rights based on that group.
Top
#113854 - 2004-02-12 02:36 AM Re: Local Admin Members
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

...but it doesn't differentiate between users and groups as members. It just spits out everything.




Can't you just enumerate the results? Would you not want to know both group and user members?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#113855 - 2004-02-12 03:07 AM Re: Local Admin Members
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I would not have the user collect this info. Instead, I would have the computer create a flag file on a server indicating it is available for interogation. A server based process would then query the workstation for any info needed outside the logon process.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113856 - 2004-02-12 10:33 AM Re: Local Admin Members
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Howard,

I don't think a server admin script would be able to do it either without using ADSI/WMI or 3rd party against NT 4.0

He said without either of those methods.

Top
#113857 - 2004-02-12 01:19 PM Re: Local Admin Members
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Yes he did say that...but the reason I think he said that ADSI was not installed on his current NT4 clients. In the scanario I put forth, he would not need ADSI on the clients just the computer from where the admin script was executed.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113858 - 2004-02-12 03:03 PM Re: Local Admin Members
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1341
Loc: NL
Dependencies: WMI enabled

Code:

Break On
$srv='\\server\share\'+@wksta+'.txt'
;$strComputer = "comp1"
If $strComputer = ""
$strComputer = "."
EndIf

Open(1,$srv,5)
$logdata='User'+Chr(9)+'Local Group'+Chr(9)+'Workstation'+Chr(9)+'OS'+Chr(9)+'Build'+Chr(9)+'SP'+Chr(9)+'NT Version'+Chr(13)+Chr(10)
$nul=WriteLine(1,$logdata)
$logdata=$name+Chr(9)+$group+Chr(9)+@Wksta+Chr(9)+@ProductType+Chr(9)+@Build+Chr(9)+@CSD+Chr(9)+@Dos+Chr(13)+Chr(10)
$nul=WriteLine(1,$logdata)
$colGroups = GetObject("WinNT://" + $strComputer + "")
If $colGroups
$colGroups.Filter = "group",""


For Each $objGroup In $colGroups
$group=$objGroup.Name

For Each $objUser In $objGroup.Members
$name=$objUser.Name
$logdata=$name+Chr(9)+$group+Chr(10)+Chr(13)
$nul=WriteLine(1,$logdata)
? $name +"-"+ $group
Sleep 1
Next
Next
EndIf
:end
$logdata=Chr(10)+Chr(13)+Chr(10)+Chr(13)
$nul=WriteLine(1,$logdata)

$nul=Close(1)




With output:

Quote:


User Local Group Workstation OS Build SP NT Version
TESTPC2 Windows XP Professional 2600 Service Pack 1 5.1
Administrator Administrators

Domain Admins Administrators

XPtest Administrators



_________________________
Co


Top
#113859 - 2004-02-12 04:26 PM Re: Local Admin Members
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hey co, I see only groups in there...
didn't he say only users
_________________________
!

download KiXnet

Top
#113860 - 2004-02-12 07:35 PM Re: Local Admin Members
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1341
Loc: NL
XPtest is a user....

Quote:

Does anyone know of a way to enumerate the members of the local admin group on a NT4 workstation (No ADSI)?


_________________________
Co


Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.078 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org