{"record":{"id":"098169056a1aabdd","repo":"ramsey/uuid","slug":"unable-to-get-a-user-identifier-using-the-system-d","errorCode":null,"errorMessage":"Unable to get a user identifier using the system DCE Security provider; please provide a custom identifier or use a different provider","messagePattern":"Unable to get a user identifier using the system DCE Security provider; please provide a custom identifier or use a different provider","errorType":"exception","errorClass":"DceSecurityException","httpStatus":null,"severity":"error","filePath":"src/Provider/Dce/SystemDceSecurityProvider.php","lineNumber":56,"sourceCode":"     * @throws DceSecurityException if unable to get a user identifier\n     *\n     * @inheritDoc\n     */\n    public function getUid(): IntegerObject\n    {\n        /** @var IntegerObject | int | float | string | null $uid */\n        static $uid = null;\n\n        if ($uid instanceof IntegerObject) {\n            return $uid;\n        }\n\n        if ($uid === null) {\n            $uid = $this->getSystemUid();\n        }\n\n        if ($uid === '') {\n            throw new DceSecurityException(\n                'Unable to get a user identifier using the system DCE Security provider; please provide a custom '\n                . 'identifier or use a different provider',\n            );\n        }\n\n        $uid = new IntegerObject($uid);\n\n        return $uid;\n    }\n\n    /**\n     * @throws DceSecurityException if unable to get a group identifier\n     *\n     * @inheritDoc\n     */\n    public function getGid(): IntegerObject\n    {\n        /** @var IntegerObject | int | float | string | null $gid */","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/ramsey/uuid/blob/da5b521600a707d2dd097598464bd3090de850f5/src/Provider/Dce/SystemDceSecurityProvider.php#L38-L74","documentation":"SystemDceSecurityProvider backs Uuid::uuid2() (DCE security, version 2). On first use it caches the POSIX UID via getSystemUid(): shell_exec('id -u') on Unix, or whoami SID parsing on Windows. If that lookup returns an empty string — shell_exec disabled, command missing, or Windows output unparsable — getUid() throws DceSecurityException telling you to supply an identifier yourself.","triggerScenarios":"Calling Uuid::uuid2() (version 2 UUID) without passing an explicit local domain identifier while shell_exec is in disable_functions, 'id' is unavailable in a minimal container, or on Windows where whoami /user output cannot be parsed. Note the empty result is cached statically, so later calls keep failing.","commonSituations":"Shared hosting and hardened PHP configs listing shell_exec in disable_functions; minimal Docker/Alpine images without coreutils; Windows/IIS environments with non-standard whoami output; CI sandboxes.","solutions":["Pass an explicit identifier: Uuid::uuid2(Uuid::DCE_DOMAIN_PERSON, 1000) (and domain), avoiding the system lookup entirely","Provide a custom DceSecurityProviderInterface implementation to UuidFactory and call $factory->uuid2()","Ask your host to enable shell_exec, or switch to Uuid::uuid1()/uuid4()/uuid6() if version-2 semantics are not required"],"exampleFix":"// before\n$uuid = \\Ramsey\\Uuid\\Uuid::uuid2(); // system UID lookup fails\n\n// after\n$uuid = \\Ramsey\\Uuid\\Uuid::uuid2(\n    \\Ramsey\\Uuid\\Uuid::DCE_DOMAIN_PERSON,\n    function_exists('posix_getuid') ? posix_getuid() : 1000,\n);","handlingStrategy":"fallback","validationCode":"if (!function_exists('shell_exec')\n    || str_contains(strtolower((string) ini_get('disable_functions')), 'shell_exec')) {\n    // system UID lookup will fail; supply an identifier\n    $uuid = \\Ramsey\\Uuid\\Uuid::uuid2(\\Ramsey\\Uuid\\Uuid::DCE_DOMAIN_PERSON, posix_getuid());\n}","typeGuard":"function canResolveSystemUid(): bool\n{\n    return function_exists('shell_exec')\n        && !str_contains(strtolower((string) ini_get('disable_functions')), 'shell_exec');\n}","tryCatchPattern":"try {\n    $uuid = \\Ramsey\\Uuid\\Uuid::uuid2($domain);\n} catch (\\Ramsey\\Uuid\\Exception\\DceSecurityException $e) {\n    $uuid = \\Ramsey\\Uuid\\Uuid::uuid2($domain, 0); // explicit placeholder identifier\n}","preventionTips":["Pass explicit domain and identifier to uuid2() in restricted environments","Check disable_functions for shell_exec before relying on system lookups","Consider posix_getuid() as your own provider instead of shell id -u"],"tags":["php","ramsey-uuid","dce-security","uuid-v2","shell-exec","disable-functions","permissions"],"backgroundTag":"posix-uid-lookup-failed","analyzedSha":"da5b521600a707d2dd097598464bd3090de850f5","analyzedAt":"2026-08-21T01:35:29.252Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}