feat: add Google LDAP vendor

Signed-off-by: Bruno Nardini <bruno.nardini@mercafacil.com>
This commit is contained in:
Bruno Nardini
2024-10-25 17:28:53 -03:00
parent a55da3189e
commit 7fc4b8ff6b
2 changed files with 14 additions and 0 deletions
@@ -25,6 +25,7 @@ import {
AEDirVendor,
ActiveDirectoryVendor,
DefaultLdapVendor,
GoogleLdapVendor,
FreeIpaVendor,
LdapVendor,
} from './vendors';
@@ -236,6 +237,7 @@ export class LdapClient {
if (this.vendor) {
return this.vendor;
}
const clientHost = this.client?.host || '';
this.vendor = this.getRootDSE()
.then(root => {
if (root && root.raw?.forestFunctionality) {
@@ -244,6 +246,8 @@ export class LdapClient {
return FreeIpaVendor;
} else if (root && 'aeRoot' in root.raw) {
return AEDirVendor;
} else if (clientHost === 'ldap.google.com') {
return GoogleLdapVendor;
}
return DefaultLdapVendor;
})
@@ -89,6 +89,16 @@ export const AEDirVendor: LdapVendor = {
},
};
export const GoogleLdapVendor: LdapVendor = {
dnAttributeName: 'dn',
uuidAttributeName: 'uid',
decodeStringAttribute: (entry, name) => {
return decode(entry, name, value => {
return value.toString();
});
},
};
// Decode an attribute to a consumer
function decode(
entry: SearchEntry,