AdjustTokenPrivileges Error if not Administrator

Jean-Pierre Ribeauville 20 Reputation points
2024-06-29T09:49:23.5966667+00:00

Hi,
I'm currently trying to make a mimic of chown by building a chown.exe using C language.
When running my app from command prompt as Administrator , it runs fine.
But when running it from "normal command prompt , it fails with AdjustTokenPrivileges Error Code 1300 when trying to set SE_RESTORE_NAME and SE_TAKE_OWNERSHIP_NAME privileges.
Despite the fact I added , in global policies, ability to take file ownership , the process has only this privileges :

PrivilegeCount(5)

name (SeShutdownPrivilege) Attributes(0)

name (SeChangeNotifyPrivilege) Attributes(3)

name (SeUndockPrivilege) Attributes(0)

name (SeIncreaseWorkingSetPrivilege) Attributes(0)

name (SeTimeZonePrivilege) Attributes(0)

Did I misunderstand something to be able to change owner o a file by this way ?
Thx for help
J.P.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,994 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,493 questions
{count} votes

Accepted answer
  1. RLWA32 42,366 Reputation points
    2024-06-29T09:58:47.9733333+00:00

    When UAC is enabled a process created by a user account that is a member of the Administrators group receives a filtered token without Administrator privileges. An elevated process that is running as Administrator will have the Administrator privileges in its token.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful