Page 1 of 1 1
Topic Options
#41892 - 2003-06-20 05:42 PM Reading Users Group list and sending to Excel spreadsheet
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi Guys

I am trying to document what groups are assigned to each user and write this information to a excel spreadsheet.

code:
Break On CLS

$sUser = "Richard.Farthing"

$objUser=GetObject("WinNT://@domain/$sUser,User")

For Each $objGroup In $objUser.Groups
$objGroup.Name ?
Next

That works but instead of displaying each group, I want to set it to a variable.

The excel part is not a problem, but this is.

Could this be done by putting it into an array and using unbound ???.

This part I am well lost.

Top
#41893 - 2003-06-20 05:46 PM Re: Reading Users Group list and sending to Excel spreadsheet
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
Break On
CLS
dim $usergroups
$sUser = "Richard.Farthing"
$objUser=GetObject("WinNT://@domain/$sUser,User")
For Each $objGroup In $objUser.Groups
redim preserve $usergroups[ubound($usergroups)+1]
$usergroups[ubound($usergroups)]=$objGroup.Name
Next



[ 20. June 2003, 18:13: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#41894 - 2003-06-20 06:11 PM Re: Reading Users Group list and sending to Excel spreadsheet
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks for getting back so fast Jens, but.... [Wink]

I don't understand it, can someone explain what it does, because I am evan more confused now [Big Grin] .

Thanks

Top
#41895 - 2003-06-20 06:16 PM Re: Reading Users Group list and sending to Excel spreadsheet
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just go through it styep by step and read the Manual. REDIM will redimensionize a variable, the new dimension will be one higher than what it used to be (pulled through UBOUND).Then the highest array element gets the group name. Then you go to the next group name in your group array.
_________________________
There are two types of vessels, submarines and targets.

Top
#41896 - 2003-06-20 09:41 PM Re: Reading Users Group list and sending to Excel spreadsheet
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Jens, YES

This is one of the very great improvements of KiXtart,

If you use UBound() on a not defined variable or a variable that is not declared as as Array it will always return -1

This in combination with the automatic typecasting in KiXtart makes it easy to write very short code.

You don't have to write code to check the vartype of the variable in question (is it an array) before using it !!

Another note:
Don't be afraid of using the ReDim statement, it is very fast, so don't overdimension your arrays. Just ReDim them as needeed.

Third note:
Build in ASCan() funktion is also very fast!

-Erik

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2175 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.138 seconds in which 0.11 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