Sign in to follow this  
Followers 0
ter-pierre

InGroup

4 posts in this topic

Hi

I get the InGroup commenti´s function to use in my logon scripts, but this funtions uses the "net user" DOS command that dont run in Windows95 or 98 workstations (to say WORKSTATIONS for this is great!).

any one knows another way to do? :)

Share this post


Link to post
Share on other sites



Ho God! I´m alone!

:)

Share this post


Link to post
Share on other sites

Excuse... :">

The "ingroup" UDF i download from this site.

That is the code:

---------------------------------------------------------------------------

Func InGroup($GROUP)

$groupnamelength = StringLen ($group)

If $groupnamelength > 21 Then

$groupnamelength = 21

EndIf

$groupnamearray = StringSplit ($GROUP,"")

$group = ""

For $groupcharactercount = 1 to $groupnamelength

$group=$group & $groupnamearray[$groupcharactercount]

Next

;Get the user details and pipe to a text file

$tempfile = tempfile()

RunWait(@ComSpec & " /c net user /Domain" & " " & @UserName & " >" & $tempfile, "", @SW_HIDE)

; Open textfile output from cmd net user

$FILE = FileOpen($tempfile, 0)

; Check if file opened for reading OK

If $FILE = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in file until the EOF is reached, if user is in group return 1 (true) or else 0 (false)

While 1

$LINE = FileReadLine($FILE) & " "

If @error = -1 Then

FileClose($FILE)

FileDelete($tempfile)

ExitLoop

EndIf

If StringInStr($LINE, "*" & $GROUP & " ") Then

FileClose($FILE)

FileDelete($tempfile)

Return 1

EndIf

WEnd

EndFunc ;==>InGroup

-----------------------------------------------------------------------

Note that to know the groups that the user is member of, the function uses the "NET USER" command. This run fine in Windows2000 or XP workstations, but this command is not recognized by Windows95 or 98.

Pierre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0