Hi All,
Could someone tell me why this fails with a 1307 (ERROR_INVALID_OWNER)
error? I've found a lot of references to theses errors on Google but no
solutions. Actually, that is where I found the suggestion that the restore
privilege should be added (doesn't work!!!).
// If we are not the current owner of the object then take ownership.
if (!EqualSid(m_pOwnerSid,
p_pAdminSID)) {
m_bRC=OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES,
&m_pToken);
if (!m_bRC) {
printf("OpenProcessToken failed - rc=%lu.", GetLastError());
goto done;
}
// Add the take ownership privilege to the current process.
m_bRC=SetPrivilege(m_pToken,
SE_TAKE_OWNERSHIP_NAME,
TRUE);
if (!m_bRC)
goto done;
m_bOwnerPrivilegeSet=TRUE;
m_bRC=SetPrivilege(m_pToken,
SE_RESTORE_NAME,
TRUE);
if (!m_bRC)
goto done;
m_bRestorePrivilegeSet=TRUE;
// Set the new owner for the object
m_dwRC=SetNamedSecurityInfo((LPSTR)p_ObjectName,
p_ObjectType,
OWNER_SECURITY_INFORMATION,
p_pAdminSID,
NULL,
NULL,
NULL);
if (ERROR_SUCCESS != m_dwRC) {
m_bRCúLSE;
printf("SetNamedSecurityInfo for owner SID failed - rc=%lu.",
m_dwRC);
goto done;
}
}
The p_pAdminSID is the SID of a group (not user) that I would like to take
ownereship of the object.
Garfield A. Lewis
Replies