Page 1 of 1 1
Topic Options
#184351 - 2008-01-01 06:45 PM KiX vs VBS behaviour
Arend_ Moderator Offline
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:
 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:
 Code:
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
#184352 - 2008-01-01 06:51 PM Re: KiX vs VBS behaviour [Re: Arend_]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Did you try & instead of and?
_________________________
(... better days ahead)

Top
#184353 - 2008-01-01 06:53 PM Re: KiX vs VBS behaviour [Re: Allen]
Arend_ Moderator Offline
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 \:D

Top
#184354 - 2008-01-01 06:55 PM Re: KiX vs VBS behaviour [Re: Arend_]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
LOL...cool. For me, that's the way to start off the year on a positive note.
_________________________
(... better days ahead)

Top
#184355 - 2008-01-01 06:58 PM Re: KiX vs VBS behaviour [Re: Allen]
Arend_ Moderator Offline
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
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 1362 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.134 seconds in which 0.074 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org