英文:
SetNamedSecurityInfo throwing error code 87
问题
我们已经面临了几个月的这个问题。
在使用Windows API函数SetNamedSecurityInfo()
时,返回错误代码87。我尝试过修复它,但无法解决。请帮我修复这个问题。
LPWSTR shareName = (LPWSTR)L"//TEST/test";
DWORD dwRes = SetNamedSecurityInfo(shareName, SE_FILE_OBJECT, SACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL);
if (ERROR_SUCCESS != dwRes) {
cout << "在SetNamedSecurityInfo中设置SACL时出错 " << dwRes << endl;
return -1;
}
我们只传递shareName
作为参数,其余参数都是常量。
通常情况下,这段代码应该在不设置任何SACL权限和不出现错误的情况下运行。
但是,在这种情况下返回错误87,这意味着“参数不正确”。但是唯一传递的参数是shareName
,如果shareName
不正确,那么函数应该返回错误67,这意味着“找不到网络名称”。
为什么在这种情况下返回错误87?
英文:
We have been facing this issue for several months.
While using the Windows API function SetNamedSecurityInfo()
, the error code 87 is returned. I have tried to fix it, but couldn't. Please help me fix this.
LPWSTR shareName = (LPWSTR)L"//TEST/test";
DWORD dwRes = SetNamedSecurityInfo(shareName, SE_FILE_OBJECT, SACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL);
if (ERROR_SUCCESS != dwRes) {
cout << "Error while setting SACL in SetNamedSecurityInfo Error " << dwRes << endl;
return -1;
}
We are passing only the shareName
as a parameter, and all the remaining parameters are constant.
Normally this code should function without setting any SACL permissions, and without any errors.
But, this is returning error 87, which means "The parameter is incorrect". But the only parameter that has been passed is the shareName
, and if the shareName
is wrong then the function should return error 67 instead, which means "The network name cannot be found".
Why is error 87 being returned in this case?
答案1
得分: 1
你正在指定 SACL_SECURITY_INFORMATION
标志,但将 pSACL
参数设置为 NULL
。这就是为什么你会收到 ERROR_INVALID_PARAMETER
(87)错误。当使用 SACL_SECURITY_INFORMATION
标志时,pSACL
参数必须指向一个有效的 SACL
对象。
英文:
You are specifying the SACL_SECURITY_INFORMATION
flag, but you are setting the pSACL
parameter to NULL
. That is why you are getting the ERROR_INVALID_PARAMETER
(87) error. When the SACL_SECURITY_INFORMATION
flag is used, the pSACL
parameter must point to a valid SACL
object.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论