Winapi:大小为SECURITY_DESCRIPTOR_MIN_LENGTH的安全描述符具有ACL

时间:2016-04-11 13:20:08

标签: winapi acl msdn dacl

我是winapi的新手,我遇到了这段代码:

PSECURITY_DESCRIPTOR SD = NULL;

Int length = SECURITY_DESCRIPTOR_MIN_LENGTH;

SD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, length);

if (SD == NULL)
{
  printf("Error! SD is null.\n");
}

if (InitializeSecurityDescriptor(SD, 
                                   SECURITY_DESCRIPTOR_REVISION) == FALSE)
{
  printf("Error in InitializeSecurityDescriptor.\n");
}

if (SetSecurityDescriptorDacl(SD, TRUE, acl, FALSE) == FALSE)
{
  printf("Error in SetSecurityDescriptorDacl.\n");
}

MSDN网站向我显示The minimum length of a security descriptor is SECURITY_DESCRIPTOR_MIN_LENGTH. A security descriptor of this length has no associated security identifiers (SIDs) or access control lists (ACLs).但是,当我测试此代码时,它工作正常。我做了很少的研究,发现了关于安全描述符的MSDN example,这里也使用了这样的代码。我想我误解了一些东西,不应该使用SECURITY_DESCRIPTOR_MIN_LENGTH然后添加ACL导致错误?对不起,如果问题听起来很傻。

0 个答案:

没有答案