问题描述
我需要用dota填充指向SECURITY_DESCRIPTOR的指针,该指针将表示某些文件和文件夹的描述符.我使用FileSecurity对象设置一些属性,然后使用GetSecurityDescriptorBinaryForm.另一方面,当应该读取我的描述符时,会收到一个错误,指出修订号不是1无效.如何在FileSecurity或Binaryform中设置该数字?
在此先谢谢您.
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.
推荐答案
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;
在文章在.NET中操作NTFS交接点中找到了代码 [ ^ ]它是一本不错的书,也许对您有用.
霍根
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
这篇关于FileSecurity修订版号.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!