Home All Groups Group Topic Archive Search About

Dotnet 2.0 bug ? Retrieving security permissions of a desktop fold

Author
19 Apr 2007 9:40 AM
gws@newsgroups.nospam
Hello,

If I get the ACL of a folder on the desktop, or for example "C:\My
Documents", I do not get the correct security settings. When I check the
security using the properties dialog with the windows explorer the right:
"Read" is true.
But when I check using the code below it returns false because the Read
right is checked twice (the first time it is set to true, the second time it
is set to false ??).

// << code example
DirectoryInfo^ dInfo = gcnew DirectoryInfo("C:\\Documents and
Settings\\USR\\Desktop\\Test2");
    DirectorySecurity^ dSecurity = dInfo->GetAccessControl();   
    AuthorizationRuleCollection^  myAc2 = dSecurity->GetAccessRules(true,
true, SecurityIdentifier::typeid);

    for (int j = 0; j < myAc2->Count; j++)
    {
       AuthorizationRule^ ac2 = myAc2[j];
       FileSystemAccessRule^ rule2 = dynamic_cast<FileSystemAccessRule^>(
ac2 );        
         if ( currentWI->User->Equals(
dynamic_cast<SecurityIdentifier^>(rule2->IdentityReference)) ) {
            if ( AccessControlType::Allow.Equals( rule2->AccessControlType ))
          {    // THIS is code is reached TWICE when dealing with a 'special'
               // folder  (desktop or My documents) while with a normal folder
              // (say d:\temp) it is reached only once. The first time
bReadRights
              // is set to true (OK) but the second time the value of
bReadRights
              // is set to false
               bool bReadRights = (((int)rule2->FileSystemRights &
(int)FileSystemRights::Read ) == (int)FileSystemRights::Read);
            }
         }

    }

// >> code example

Can anyone help me with this problem ?

Thanks in advance,

martin

AddThis Social Bookmark Button