Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to fill pointer to SECURITY_DESCRIPTOR with dota that will represent descriptors of certain files and folders. I use FileSecurity object set some properties and then use GetSecurityDescriptorBinaryForm. On the other end of that when my descriptor should be read it gets an error that revision number other than 1 is invalid. How to set that number either in FileSecurity or binaryform?
Thanks in advance.
Posted

1 solution

Try something like this:

C#
SECURITY_ATTRIBUTES lpSecurityAttributes = new SECURITY_ATTRIBUTES();
DirectorySecurity security = new DirectorySecurity();
lpSecurityAttributes.nLength = Marshal.SizeOf(lpSecurityAttributes);
byte[] src = security.GetSecurityDescriptorBinaryForm();
IntPtr dest = Marshal.AllocHGlobal(src.Length);
Marshal.Copy(src, 0, dest, src.Length);
lpSecurityAttributes.lpSecurityDescriptor = dest;


Found the code in the article Manipulating NTFS Junction Points in .NET[^] Its a good read and may just do the trick for you.

Hogan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900