By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Howto get the right properties for a desktop folder ??

P: n/a
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 ?

Apr 24 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.