{"record":{"id":"b07fc472e73c5449","repo":"passbolt/passbolt_api","slug":"a-mapping-rule-for-id-attribute-could-not-be-found-for","errorCode":null,"errorMessage":"A mapping rule for ID attribute could not be found for directory type: {0}","messagePattern":"A mapping rule for ID attribute could not be found for directory type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryResults.php","lineNumber":272,"sourceCode":"        return $ldapUser;\n    }\n\n    /**\n     * Adds a uuid to the ldap object if not present and if a dn exists.\n     *\n     * @param \\LdapRecord\\Models\\Entry $ldapObject ldap object\n     * @return \\LdapRecord\\Models\\Entry ldap object\n     * @throws \\RuntimeException A mapping rule for ID attribute could not be found for the directory type\n     */\n    protected function _transformId(Entry $ldapObject): Entry\n    {\n        /** @var string $type */\n        $type = $ldapObject->getFirstAttribute('objectType');\n        /** @var string $directoryType */\n        $directoryType = $ldapObject->getFirstAttribute('directoryType');\n        $idAttribute = $this->mappingRules[$directoryType][$type]['id'] ?? null;\n        if (!$idAttribute) {\n            throw new RuntimeException(\n                __('A mapping rule for ID attribute could not be found for directory type: {0}', $directoryType)\n            );\n        }\n        $dn = $ldapObject->getDn();\n        if (!$ldapObject->hasAttribute($idAttribute) && $dn) {\n            /** @psalm-suppress InvalidArgument it takes args, not an array */\n            $ldapObject->setAttribute($idAttribute, UuidFactory::uuid($dn));\n        } else {\n            $ldapObject->setAttribute($idAttribute, $ldapObject->getConvertedGuid());\n        }\n\n        return $ldapObject;\n    }\n\n    /**\n     * Populate groups list from Ldap results.\n     *\n     * @return void","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Utility/DirectoryEntry/DirectoryResults.php#L254-L290","documentation":"DirectoryResults::_transformId resolves the LDAP attribute that uniquely identifies an object (user or group) from mappingRules[directoryType][objectType]['id']. When that mapping is absent it cannot determine the object's unique ID and throws, listing the directoryType.","triggerScenarios":"Calling transformLdapUser or transformLdapGroup for an object whose directoryType has no ['id'] rule for its objectType in the mapping rules array.","commonSituations":"Corrupted or hand-edited directory settings removing the 'id' mapping; LDAP entry with an objectClass the mappings do not cover (e.g. custom group class); directoryType attribute missing/renamed on the LDAP server so lookup keys mismatch.","solutions":["Restore/refresh the default mapping rules by re-saving directory sync settings from the admin UI","Confirm mappingRules[directoryType][objectType]['id'] is present (typically 'objectguid' for AD, 'entryuuid' for OpenLDAP)","Check the LDAP entry's objectClass/directoryType attributes match what the configured mappings expect","Extend the mapping rules for custom object classes in the directory settings"],"exampleFix":"// before\n$idAttribute = $this->mappingRules[$directoryType][$type]['id'] ?? null;\nif (!$idAttribute) {\n    throw new RuntimeException(\n        __('A mapping rule for ID attribute could not be found for directory type: {0}', $directoryType)\n    );\n}\n// after\n$idAttribute = $this->mappingRules[$directoryType][$type]['id'] ?? null;\nif (!$idAttribute) {\n    Log::warning(\"Missing id mapping for type={$type} directoryType={$directoryType}\");\n    throw new RuntimeException(\n        __('A mapping rule for ID attribute could not be found for directory type: {0}', $directoryType)\n    );\n}","handlingStrategy":"validation","validationCode":"$rules = $mappingRules[$directoryType][$objectType] ?? [];\nif (empty($rules['id'])) { /* configure id mapping (objectguid/entryuuid) first */ }","typeGuard":"$idAttribute = $mappingRules[$directoryType][$objectType]['id'] ?? null;\nif (!is_string($idAttribute) || $idAttribute === '') { return null; }","tryCatchPattern":"try {\n    $entry = $results->transformLdapGroup($ldapGroup);\n} catch (RuntimeException $e) {\n    $this->log($e->getMessage()); // inspect directoryType/id mapping\n}","preventionTips":["Ensure each objectType in mappings defines an 'id' attribute (objectguid for AD, entryuuid for OpenLDAP)","Restrict LDAP filters to object classes covered by your mappings","Re-generate mappings via the admin settings form rather than manual JSON edits"],"tags":["ldap","mapping","configuration"],"backgroundTag":"missing-config-key","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}