关于SetSecurityDescriptorDacl函数的使用

来源:互联网 发布:14马刺知乎 编辑:程序博客网 时间:2024/06/01 07:34

参考资料来源:http://msdn.microsoft.com/en-us/library/aa379583(VS.85).aspx

此函数用来设置DACL中的信息。如果一个DACL已经在security descriptor中存在,那么此DACL将被替换。

函数原型如下:

要想使用第三、四两个参数,那么参数二需要设置为TRUE;如果参数二设置为FALSE,那么参数三、四被忽略。

值得注意的是MSDN中的Remarks中有这样的描述:

There is an important difference between an empty and a nonexistent DACL.

  • When a DACL is empty, it contains no access control entries (ACEs); therefore, no access rights are explicitly granted. As a result, access to the object is implicitly denied.
  • When an object has no DACL (when the pDacl parameter is NULL), no protection is assigned to the object, and all access requests are granted. To help maintain security, restrict access by using a DACL.把参数三设置为NULL,其实相当于将object的安全级别降到了最低,所有的访问请求都将成功。