mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-05 05:18:51 +00:00
(fix) we update the baseDN placeholders of all LDAP sources upon login
This commit is contained in:
@@ -529,10 +529,8 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
|
||||
grace: (int *) _grace
|
||||
{
|
||||
NGLdapConnection *bindConnection;
|
||||
NSMutableString *s;
|
||||
NSString *userDN;
|
||||
BOOL didBind;
|
||||
NSRange r;
|
||||
|
||||
didBind = NO;
|
||||
|
||||
@@ -542,14 +540,7 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
|
||||
// We check if SOGo admins have deviced a top-level SOGoUserSources with a dynamic base DN.
|
||||
// This is a supported multi-domain configuration. We alter the baseDN in this case by extracting
|
||||
// the domain from the login.
|
||||
r = [_login rangeOfString: @"@"];
|
||||
if (r.location != NSNotFound &&
|
||||
[_pristineBaseDN rangeOfString: @"%d"].location != NSNotFound)
|
||||
{
|
||||
s = [NSMutableString stringWithString: _pristineBaseDN];
|
||||
[s replaceOccurrencesOfString: @"%d" withString: [_login substringFromIndex: r.location+1] options: 0 range: NSMakeRange(0, [s length])];
|
||||
ASSIGN(_baseDN, s);
|
||||
}
|
||||
[self updateBaseDNFromLogin: _login];
|
||||
|
||||
bindConnection = [[NGLdapConnection alloc] initWithHostName: _hostname
|
||||
port: _port];
|
||||
@@ -1971,4 +1962,19 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) updateBaseDNFromLogin: (NSString *) theLogin
|
||||
{
|
||||
NSMutableString *s;
|
||||
NSRange r;
|
||||
|
||||
r = [theLogin rangeOfString: @"@"];
|
||||
if (r.location != NSNotFound &&
|
||||
[_pristineBaseDN rangeOfString: @"%d"].location != NSNotFound)
|
||||
{
|
||||
s = [NSMutableString stringWithString: _pristineBaseDN];
|
||||
[s replaceOccurrencesOfString: @"%d" withString: [theLogin substringFromIndex: r.location+1] options: 0 range: NSMakeRange(0, [s length])];
|
||||
ASSIGN(_baseDN, s);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -683,7 +683,9 @@ static Class NSNullK;
|
||||
|
||||
// We MUST, for all LDAP sources, update the bindDN and bindPassword
|
||||
// to the user's value if bindAsCurrentUser is set to true in the
|
||||
// LDAP source configuration
|
||||
// LDAP source configuration.
|
||||
//
|
||||
// We also update the baseDN of all sources.
|
||||
if (checkOK)
|
||||
{
|
||||
NSObject <SOGoDNSource> *currentSource;
|
||||
@@ -697,6 +699,7 @@ static Class NSNullK;
|
||||
{
|
||||
[currentSource setBindDN: [currentSource lookupDNByLogin: _login]];
|
||||
[currentSource setBindPassword: _pwd];
|
||||
[currentSource updateBaseDNFromLogin: _login];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user