|
|
@@ -58,7 +58,7 @@ class LdapService {
|
|
|
* @param {string} userBindUsername Necessary when bind type is user bind
|
|
|
* @param {string} userBindPassword Necessary when bind type is user bind
|
|
|
*/
|
|
|
- bind(userBindUsername?: string, userBindPassword?: string): Promise<void> {
|
|
|
+ bind(userBindUsername = '', userBindPassword = ''): Promise<void> {
|
|
|
const client = this.client;
|
|
|
if (client == null) throw new Error('LDAP client is not initialized');
|
|
|
|
|
|
@@ -71,8 +71,8 @@ class LdapService {
|
|
|
|
|
|
// get configurations
|
|
|
const isUserBind = configManager?.getConfig('crowi', 'security:passport-ldap:isUserBind');
|
|
|
- const bindDN = configManager?.getConfig('crowi', 'security:passport-ldap:bindDN');
|
|
|
- const bindCredentials = configManager?.getConfig('crowi', 'security:passport-ldap:bindDNPassword');
|
|
|
+ const bindDN = configManager?.getConfig('crowi', 'security:passport-ldap:bindDN') ?? '';
|
|
|
+ const bindCredentials = configManager?.getConfig('crowi', 'security:passport-ldap:bindDNPassword') ?? '';
|
|
|
|
|
|
// user bind
|
|
|
const fixedBindDN = (isUserBind)
|
|
|
@@ -146,12 +146,12 @@ class LdapService {
|
|
|
return this.search(undefined, this.getGroupSearchBase());
|
|
|
}
|
|
|
|
|
|
- getArrayValFromSearchResultEntry(entry: SearchResultEntry, attributeType: string): string[] {
|
|
|
+ getArrayValFromSearchResultEntry(entry: SearchResultEntry, attributeType: string | undefined): string[] {
|
|
|
const values: string | string[] = entry.attributes.find(attribute => attribute.type === attributeType)?.values || [];
|
|
|
return typeof values === 'string' ? [values] : values;
|
|
|
}
|
|
|
|
|
|
- getStringValFromSearchResultEntry(entry: SearchResultEntry, attributeType: string): string | undefined {
|
|
|
+ getStringValFromSearchResultEntry(entry: SearchResultEntry, attributeType: string | undefined): string | undefined {
|
|
|
const values: string | string[] | undefined = entry.attributes.find(attribute => attribute.type === attributeType)?.values;
|
|
|
if (typeof values === 'string' || values == null) {
|
|
|
return values;
|
|
|
@@ -163,8 +163,9 @@ class LdapService {
|
|
|
}
|
|
|
|
|
|
getGroupSearchBase(): string {
|
|
|
- return configManager?.getConfig('crowi', 'external-user-group:ldap:groupSearchBase')
|
|
|
- || configManager?.getConfig('crowi', 'security:passport-ldap:groupSearchBase');
|
|
|
+ return configManager.getConfig('crowi', 'external-user-group:ldap:groupSearchBase')
|
|
|
+ ?? configManager.getConfig('crowi', 'security:passport-ldap:groupSearchBase')
|
|
|
+ ?? '';
|
|
|
}
|
|
|
|
|
|
}
|