Page 1 of 1 1
Topic Options
#51837 - 2000-10-17 03:53 PM retrieving all groups for a user
Anonymous
Unregistered


Okay, I'm trying to get a list of all the groups that a user belongs to and that info to a text file. Here is what I tried:

shell '%comspec% /c echo groups @ingroup >group.txt

This works great for getting userid, fullname, and primary group (using the appropriate macros of course) but @ingroup returns errors. I know this macro allows you to look for a specific group but I need to pull all global groups for the users. Has anyone done this?

Top
#51838 - 2000-10-17 04:43 PM Re: retrieving all groups for a user
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
code:

$index = 0
$groups = ""
$cr = chr(13)+chr(10)

do
$groups = $groups + enumgroup($index) + $cr
$index = $index + 1
until enumgroup($index) = ""

? $groups




Top
#51839 - 2000-10-17 07:02 PM Re: retrieving all groups for a user
Anonymous
Unregistered


Bryce,

How then do I get it to add a line to the text file?

Top
#51840 - 2000-10-17 07:52 PM Re: retrieving all groups for a user
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Use the open() and writeline() commands.

code:

$index = 0
$groups = ""

$cr = chr(13)+chr(10)
$file = "groups.txt"

if exist($file) = 1 del $file endif

do
$groups = $groups + enumgroup($index) + $cr
$index = $index + 1
until enumgroup($index) = ""

$nul = open(1,$file,5)
$nul = writeline(1,$groups)
$nul = close(1)

? "@curdir$file was created that contains all global groups that @userid was a member of"



Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.052 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

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