Page 1 of 1 1
Topic Options
#87639 - 2002-09-04 10:15 PM Use WMI to Check Registry Access Permissions
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I'd like some opinions before I submit this to the UDF forum.

code:
Break On CLS

If CheckAccess(,"System\CurrentControlSet\Services\LanmanServer\Parameters","qs") = 0
"User has Query and Set Value permissions." ?
Else
"User cannot write to this key." ?
Endif

;Q = KEY_QUERY_VALUE
;S = KEY_SET_VALUE
;C = KEY_CREATE_SUB_KEY
;E = KEY_ENUMERATE_SUB_KEYS
;N = KEY_NOTIFY
;L = KEY_CREATE_LINK
;D = DELETE
;R = READ_CONTROL
;W = WRITE_DAC
;O = WRITE_OWNER

Function CheckAccess(Optional $Key, $Path, Optional $Access, Optional $strComputer)
Select
Case $Key = "HKEY_CLASSES_ROOT" $Key = &80000000
Case $Key = "HKEY_CURRENT_USER" $Key = &80000001
Case $Key = "HKEY_LOCAL_MACHINE" $Key = &80000002
Case $Key = "HKEY_USERS" $Key = &80000003
Case $Key = "HKEY_CURRENT_CONFIG" $Key = &80000005
Case $Key = "HKEY_DYN_DATA" $Key = &80000006
Case 1 $Key = &80000002
EndSelect

If instr($Access, "Q") $Perms = $Perms + &1 Endif
If instr($Access, "S") $Perms = $Perms + &2 Endif
If instr($Access, "C") $Perms = $Perms + &4 Endif
If instr($Access, "E") $Perms = $Perms + &8 Endif
If instr($Access, "N") $Perms = $Perms + &10 Endif
If instr($Access, "L") $Perms = $Perms + &20 Endif
If instr($Access, "D") $Perms = $Perms + &10000 Endif
If instr($Access, "R") $Perms = $Perms + &20000 Endif
If instr($Access, "W") $Perms = $Perms + &40000 Endif
If instr($Access, "O") $Perms = $Perms + &80000 Endif

If $strComputer = "" $strComputer = "." Endif
$objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\default:StdRegProv")

$CheckAccess = $objRegistry.CheckAccess($Key, $Path, $Perms)
EndFunction


Top
#87640 - 2002-09-05 09:45 PM Re: Use WMI to Check Registry Access Permissions
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Is this a big, fat, 'who cares?' Or, does anyone see any value in this?
Top
#87641 - 2002-09-05 09:57 PM Re: Use WMI to Check Registry Access Permissions
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Oh, I do see use in it but haven't had time to try it out. I'd say, submit it to the UDF forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#87642 - 2002-09-05 10:10 PM Re: Use WMI to Check Registry Access Permissions
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I checked it out and thought it was really cool ... and usefull to ... I agree with Jens ... post it to the UDF forum ...

-Shawn

[ 05. September 2002, 22:11: Message edited by: Shawn ]

Top
#87643 - 2002-09-05 10:30 PM Re: Use WMI to Check Registry Access Permissions
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Well, that's all the endorsement I need then. [Wink]

I'll look at the other registry functions of WMI as well when I get time. Can probably come up with a way to set values on remote PC's using 'admin' scripts.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.106 seconds in which 0.083 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