Hello davepl-ga,
Here you go (in VBScript):
-------------------------------------------------------------------
<HTML>
<HEAD><TITLE>Admin Groups Detector</TITLE>
</HEAD>
<BODY>
<H3>This page will detect if you are part of the administrator's group...</H3><HR>
<INPUT TYPE="button" NAME="button" VALUE="Check Admin Rights" onClick
= 'blnIsMemberOfAdminGroup()'>
<SCRIPT LANGUAGE="VBScript">
Function LoggedOnUser()
On Error Resume Next
Set objNet = CreateObject("WScript.Network")
If err.Number <> 0 Then
Msgbox "Error occured: " & err.Description
Exit Function
End If
strAccount = objNet.UserDomain & "/" & objNet.UserName
If strAccount = "" Then
If err.Number <> 0 Then
Msgbox "Error occured: " & err.Description
Exit Function
End If
Else
LoggedOnUser = strAccount
End If
On Error GoTo 0
End Function
Function blnIsMemberOfAdminGroup()
On Error Resume Next
blnIsMemberOfAdminGroup = False
strUserName = LoggedOnUser()
If strUserName = "" Then
Msgbox "Unable to find the logged on username."
Exit Function
End If
Set objShell = CreateObject("WScript.Shell")
strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
strCommand = "cmd.exe /c net localgroup administrators"
Set objShellScriptExec = objShell.Exec(strCommand)
Set objStdOut = objShellScriptExec.StdOut
strLine = objStdOut.ReadAll
strUserName = Replace(strUserName, strComputerName & "/", "")
If InStr(UCase(strLine), UCase(strUserName)) > 0 Then
blnIsMemberOfAdminGroup = True
msgbox "You are a member of administrator group on this
PC.",vbOKOnly + vbInformation
Else
msgbox "You are NOT an administrator on this PC.",vbOKOnly + vbCritical
End If
On Error Goto 0
End Function
</SCRIPT>
</BODY>
</HTML>
-------------------------------------------------------------------
I also found this link, but the above seemed a better choice:
http://www.windowsitpro.com/Files/07/49702/Listing_01.txt
All the best,
tisme-ga |
Request for Answer Clarification by
davepl-ga
on
07 Aug 2006 11:53 PDT
This code looks promising, but when I run it and click the button I
get an error popup:
Error occured: ActiveX component can't create object.
|
Request for Answer Clarification by
davepl-ga
on
07 Aug 2006 11:58 PDT
BTW, I am surmising that this is because the WScript.Network control
might not be marked as safe for scripting. So you really need to
limit yourself to controls that ARE marked safe for scripting.
|
Request for Answer Clarification by
davepl-ga
on
08 Aug 2006 11:28 PDT
This "answer" does not work, but the question is marked as answered.
How do I reject an answer and ask for it to be reposted?
Thanks,
Dave
|
Clarification of Answer by
tisme-ga
on
08 Aug 2006 12:27 PDT
Hello davepl-ga,
I am still researching and working on this for you. Do you have
windows scripting installed?
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
I am still looking into the error message.
tisme-ga
|
Request for Answer Clarification by
davepl-ga
on
14 Aug 2006 09:33 PDT
I can install anything you need on the SERVER side, but the client
that winds up visiting the site may not have anything more than a
vanilla Windows XP installation.
The problem with the first solution posted is that the control(s) you
were trying to use are not marked as "safe for scripting". The
default security settings for Windows do not allow the client to run
scripts with controls that are not marked "safe for scripting".
Your earlier solution would work if the user changed their default
security settings, but of course that's not practical in the real
world, where you have to assume users are runnind defaults.
|