#184351 - 2008-01-01 06:45 PM
KiX vs VBS behaviour
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
First and foremost I want to wish everyone a happy new year, hope it will bring you the answers to the questions you had last year 
That aside as most of you know I code a lot involving security, this time I'm attempting to read every Ace from an ACL (Access Client List) from a file or folder. This is easy enough however I want to find out which AccessMask each Ace has (even that is easy enough) but then further split it to find out which permisssions that AccessMask contains, this is seemingly harder then it looks in KiX then it is in VBS, so I'm hoping one of you Guru's out there has the answer.
I'll present 2 pieces of code, both exactly the same. 1 is in KiX code, the other in VBS. To use them create a folder on your C:\ drive called "ACLtest" and remove all Aces. Just add 1 and give it FULL (or at least READ) permissions.
Kix code:
Dim $adsu, $sd, $dacl, $ace, $ADS_RIGHT_READ
$ADS_RIGHT_READ = &20000
$adsu = CreateObject("ADsSecurityUtility")
$sd = $adsu.GetSecurityDescriptor("C:\ACLTest",1,1)
$dacl = $sd.DiscretionaryAcl
For Each $ace in $dacl
If (($ace.AccessMask And $ADS_RIGHT_READ) = $ADS_RIGHT_READ)
? "True"
Else
? "False"
EndIf
Next
And it's VBS counterpart:
Dim adsu, sd, dacl, ace
CONST ADS_RIGHT_READ = &H20000
Set adsu = CreateObject("ADsSecurityUtility")
Set sd = adsu.GetSecurityDescriptor("C:\ACLTest",1,1)
Set dacl = sd.DiscretionaryAcl
For Each ace in dacl
If ((ace.AccessMask And ADS_RIGHT_READ) = ADS_RIGHT_READ) Then
WScript.Echo "True"
Else
WScript.Echo "False"
End If
Next
The weird thing is, the AccesMask returned in both VBS and KiX are exactly the same, no weird stuff here, however VBS will return TRUE and KiX will return FALSE. I don't get it after spending many late hours trying to figure this out, I hope someone can help me with this.
|
|
Top
|
|
|
|
#184353 - 2008-01-01 06:53 PM
Re: KiX vs VBS behaviour
[Re: Allen]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
LOL, no THAT I didn't try and seemingly thats the answer  Thanks alot Allen
|
|
Top
|
|
|
|
#184355 - 2008-01-01 06:58 PM
Re: KiX vs VBS behaviour
[Re: Allen]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
I can't believe I didn't think of that one myself.... Always good to have someone take a fresh look at things. You certainly got my gratitude and best wishes for the new year
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1362 anonymous users online.
|
|
|