function SystemDceSecurityProvider::getWindowsUid
Returns the user identifier for a user on a Windows system
Windows does not have the same concept as an effective POSIX UID for the running script. Instead, each user is uniquely identified by an SID (security identifier). The SID includes three 32-bit unsigned integers that make up a unique domain identifier, followed by an RID (relative identifier) that we will use as the UID. The primary caveat is that this UID may not be unique to the system, since it is, instead, unique to the domain.
@link https://www.lifewire.com/what-is-an-sid-number-2626005 What Is an SID Number? @link https://bit.ly/30vE7NM Well-known SID Structures @link https://bit.ly/2FWcYKJ Well-known security identifiers in Windows operating systems @link https://www.windows-commandline.com/get-sid-of-user/ Get SID of user
File
-
vendor/
ramsey/ uuid/ src/ Provider/ Dce/ SystemDceSecurityProvider.php, line 169
Class
- SystemDceSecurityProvider
- SystemDceSecurityProvider retrieves the user or group identifiers from the system
Namespace
Ramsey\Uuid\Provider\DceCode
private function getWindowsUid() : string {
$response = shell_exec('whoami /user /fo csv /nh');
if ($response === null) {
return '';
}
$sid = str_getcsv(trim((string) $response))[1] ?? '';
if (($lastHyphen = strrpos($sid, '-')) === false) {
return '';
}
return trim(substr($sid, $lastHyphen + 1));
}