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.