X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=SoObjects%2FSOGo%2FSOGoAuthenticator.m;h=134dba0235f104ae0eef91ddfd45e4583481b28e;hb=ab66b6ca55944e8393de4ccf5c4608bd34c83f5e;hp=00205e6fd373242f8f45ea87ded6f94850b41672;hpb=219ffc26210dcc8b83cb64733091c56b3bfa0060;p=scalable-opengroupware.org diff --git a/SoObjects/SOGo/SOGoAuthenticator.m b/SoObjects/SOGo/SOGoAuthenticator.m index 00205e6f..134dba02 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.m +++ b/SoObjects/SOGo/SOGoAuthenticator.m @@ -22,9 +22,11 @@ #import #import "SOGoPermissions.h" -#include "SOGoAuthenticator.h" -#include "SOGoUser.h" -#include "common.h" +#import "LDAPUserManager.h" + +#import "SOGoAuthenticator.h" +#import "SOGoUser.h" +#import "common.h" @implementation SOGoAuthenticator @@ -50,9 +52,9 @@ static SOGoAuthenticator *auth = nil; authMethod = [[ud stringForKey:@"AuthentificationMethod"] retain]; if ([authMethod isEqualToString: @"LDAP"]) { - LDAPBaseDN = [[ud stringForKey:@"LDAPRootDN"] retain]; - LDAPHost = [[ud stringForKey:@"LDAPHost"] retain]; - LDAPPort = [ud integerForKey:@"LDAPPort"]; +// LDAPBaseDN = [[ud stringForKey:@"LDAPRootDN"] retain]; +// LDAPHost = [[ud stringForKey:@"LDAPHost"] retain]; +// LDAPPort = [ud integerForKey:@"LDAPPort"]; } } @@ -72,63 +74,65 @@ static SOGoAuthenticator *auth = nil; - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd { - BOOL result; + BOOL accept; -// return YES; if ([authMethod isEqualToString: @"LDAP"]) - result = [self LDAPCheckLogin: _login password: _pwd]; + accept = [self LDAPCheckLogin: _login password: _pwd]; else - { - if ([_login length] == 0) - result = NO; - else - result = YES; - } + accept = ([_login length] > 0); - return result; + return (([_login isEqualToString: @"freebusy"] + && [_pwd isEqualToString: @"freebusy"]) + || accept); } - (BOOL) LDAPCheckLogin: (NSString *) _login password: (NSString *) _pwd { - return [NGLdapConnection checkPassword: _pwd - ofLogin: _login - atBaseDN: LDAPBaseDN - onHost: LDAPHost - port: LDAPPort]; + LDAPUserManager *um; + + um = [LDAPUserManager sharedUserManager]; + + return [um checkLogin: _login andPassword: _pwd]; } /* create SOGoUser */ -- (SoUser *) userInContext:(WOContext *)_ctx +- (SOGoUser *) userInContext: (WOContext *)_ctx { - static SoUser *anonymous = nil, *freebusy; - NSString *login; - + static SOGoUser *anonymous = nil, *freebusy; + SOGoUser *user; + NSArray *traversalPath; + NSString *login; + if (!anonymous) anonymous - = [[SOGoUser alloc] initWithLogin:@"anonymous" + = [[SOGoUser alloc] initWithLogin: @"anonymous" roles: [NSArray arrayWithObject: SoRole_Anonymous]]; - if (!freebusy) freebusy = [[SOGoUser alloc] initWithLogin: @"freebusy" roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]]; - if ((login = [self checkCredentialsInContext:_ctx]) == nil) - /* some error (otherwise result would have been anonymous */ - return nil; - - if ([login isEqualToString: @"anonymous"]) - return anonymous; - else if ([login isEqualToString: @"freebusy"]) - return freebusy; - -// uroles = [NSMutableArray arrayWithArray: ]; + login = [self checkCredentialsInContext:_ctx]; + if (login) + { + if ([login isEqualToString: @"anonymous"]) + { + traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"]; + if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"]) + user = freebusy; + else + user = anonymous; + } + else + user = [SOGoUser userWithLogin: login + roles: [self rolesForLogin: login]]; + } + else + user = nil; - return [[[SOGoUser alloc] initWithLogin: login - roles: [self rolesForLogin: login]] - autorelease]; + return user; } // - (BOOL) renderException: (NSException *) exception