#147584 - 2005-09-12 02:57 PM
If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
I need a script that checks if a user is member of a group that contains a certain word. Let's say I need to know where a user is admin and I have groups like "New York Admin", "Dallas Admin" etc, so I want to enumerate the membership of all groups with Admin in the name.
can someone help me PLEASE!
thanx Rick
Edited by talismaniak (2005-09-12 03:00 PM)
|
Top
|
|
|
|
#147585 - 2005-09-12 03:07 PM
Re: If groupname contains...
|
Bryce
KiX Supporter
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Code:
$localgroups = getobject('WinNT://' + @wksta) $localgroups.filter = 'group','' for each $group in $localgroups if instr($group.name,'admin') ;this local group has 'admin' in it's name ? $group.name endif next
|
Top
|
|
|
|
#147587 - 2005-09-12 09:22 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
Thanx for the code, I managed to enum the groups too, but this looks better.. How can I put those "admin" groups in an array so that I can use the found groups later in my script?? I allready found a enumgrouparray function on the net, but I can't get it to work... Can you help me out again??
|
Top
|
|
|
|
#147588 - 2005-09-12 10:09 PM
Re: If groupname contains...
|
Bryce
KiX Supporter
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Code:
$localgroups = getobject('WinNT://' + @wksta) $localgroups.filter = 'group',''
DIM $admingroups[0]
for each $group in $localgroups if instr($group.name,'admin') ;this local group has 'admin' in it's name $admingroups[$i] = $group $i = $i + 1 redim preserve $admingroups[$i] EndIf next
If $i redim preserve $admingroups[$i-1] Else $admingroups=0 EndIf
for each $group in $admingroups ? $group.name next
|
Top
|
|
|
|
#147590 - 2005-09-12 11:42 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
Hi, thank you all.. Sorry for my bad English, but I need this for the current users membership only. I will explain why: I want to check which rights the person has and then supply him with an options menu based on that query (applicable to every query I choose). In this example "admin".
Let's say he is member of Miami Admins and New York Admins. He starts the script and the script runs a query on "admin". It returns those two groups that will appear in his menu like
"Select your options: 1. Miami Admin options 2. New York Admin options"
This script would make my life so much easier ;-))
|
Top
|
|
|
|
#147592 - 2005-09-13 12:10 AM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
Jooel, I get an error when I run your code. It says: ERROR : invalid method/function call: missing required parameter 1! on line 2...
How can I use the groups within the script to build the menu?
|
Top
|
|
|
|
#147594 - 2005-09-13 02:14 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
Damn I can't get it to work, I'm learning scripting by the minute, but I'm still unable to understand how i use the groupnames at a later stage in the script.
|
Top
|
|
|
|
#147596 - 2005-09-15 05:50 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
So I use the script Bryce wrote, I should be able to display a group witth the command "? $admingroups[1]"? This results in "IDispatch pointers not allowed in expressions!"
|
Top
|
|
|
|
#147599 - 2005-09-16 02:39 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
I'm running that script just to figure out how I can make use of the enumerated groups. What I want is when a user logs on, the groups containing a certain word are shown, then a user can make his selection which one he wants to start... So I thought:
for each $group in $admingroups ? $group.name Get $x ? users selection is $admingroups[$x]
and then something like: net use g: \\server\$admingroup[$x]
Must be possible somehow...
|
Top
|
|
|
|
#147601 - 2005-09-16 03:03 PM
Re: If groupname contains...
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here's one way to do it, this presents groups with the letter "o" in them: Code:
Break ON $=SetOption("Explicit","ON") $=SetOption("WrapAtEOL","ON") Dim $iIndex, $sGroup, $sAllGroups $iIndex=0 $sGroup=EnumGroup($iIndex) While Not @ERROR AND $sGroup $iIndex=$iIndex+1 If InStr($sGroup,"o") $sAllGroups=$sAllGroups+@CRLF+$sGroup EndIf $sGroup=EnumGroup($iIndex) Loop $sAllGroups=Split($sAllGroups,@CRLF) For $iIndex=1 to UBound($sAllGroups) CStr($iIndex)+". "+$sAllGroups[$iIndex]+@CRLF Next "Enter a number between 1 and "+($iIndex-1)+" : " GetS $iIndex $iIndex=Val($iIndex) If $iIndex>0 AND $iIndex<UBound($sAllGroups) "You selected group '"+$sAllGroups[$iIndex]+@CRLF Else "You made an invalid selection"+@CRLF EndIf
|
Top
|
|
|
|
#147603 - 2005-09-16 04:14 PM
Re: If groupname contains...
|
talismaniak
Fresh Scripter
Registered: 2005-09-12
Posts: 12
|
Brilliant!! thanks... Now I can think of the next step.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
2023-09-28 [Arend_]
Wow even the shouts are old ;-)
2023-11-17 [Dr_Rick]
I love Kixforms!
2023-11-21 [Dave_Melczer]
Getting DB errors again opening posts...anyone else?
2023-11-24 [Flavien]
DB errors confirmed. This forum is showing its age... UBB 7.2.2 is from 2007
2023-11-27 [Sealeopard]
And there goes the forum :-(
2023-11-30 [NTDOC]
Yes, so old no good easy update path
2023-12-01 [mole]
Posts back. No DB errors. Thanks!
2023-12-29 [BradV]
Happy new year!
2024-02-09 [RSLHA]
No access possible!
2024-02-09 [RSLHA]
Database Error!
2024-02-18 [Dr_Rick]
What happened to Bruno
2024-03-08 [mole]
Thanks for getting the posts back again.
2024-04-18 [MarineV]
will the db errors get fixed????
2024-04-26 [Tonny]
database error, please!
2024-05-09 [NTDOC]
I'm not seeing any errors
2024-05-31 [chojin]
DB is down again
2024-06-04 [selsner]
Still no access, please help!
2024-06-07 [mole]
Looks like DB is back again. Thanks.
2024-06-17 [It_took_my_meds]
We encountered a problem. The reason reported was Database error only visible to forum administrators Please click back to return to the previous page.
2024-07-04 [Armin73]
There is still a database error 🤷♂️
2024-07-09 [0neZero]
There is still a database error 🤷♂️
2024-07-10 [Allen]
DB working a few times in between the messages above. Working again as of 7/10. Thanks Doc
2024-08-31 [NetGnostic]
Bummer, the Database error is back.
2024-09-04 [NTDOC]
Fourms are back up without error for the moment
2024-10-02 [Arend_]
Wll still have database errors ;-)
2024-10-03 [Allen]
Thanks to Doc... it's back.
2024-12-09 [chojin]
could we move kixtart to a new place in order to keep it living ? maybe create a github page and a subreddit?
2024-12-10 [Allen]
do know about moving it, but I know Doc is aware of the DB issue. Should be back online soon.
2024-12-10 [Allen]
don't know...
|
|
0 registered
and 303 anonymous users online.
|
|
|