From 0a646d8406c73e4a5934d4ab86eacb721dab3708 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 23 Jul 2007 18:59:09 +0000 Subject: [PATCH] fixed OGo bug #1888 git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1515 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-ldap/NGLdap/ChangeLog | 9 ++++++++ sope-ldap/NGLdap/NGLdapConnection.h | 13 +++++++++-- sope-ldap/NGLdap/NGLdapConnection.m | 34 ++++++++++++++++++++++++++--- sope-ldap/NGLdap/Version | 2 +- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/sope-ldap/NGLdap/ChangeLog b/sope-ldap/NGLdap/ChangeLog index fe350a0a..e3d281dd 100644 --- a/sope-ldap/NGLdap/ChangeLog +++ b/sope-ldap/NGLdap/ChangeLog @@ -1,3 +1,12 @@ +2007-07-23 Helge Hess + + * changed API to use NSTimeInterval, added missing getter methods + (v4.7.31) + +2007-07-23 Wolfgang Sourdeau + + * added methods to specify query time and size limits (OGo bug #1888) + 2006-07-04 Helge Hess * use %p for pointer formats, fixed gcc 4.1 warnings, minor code diff --git a/sope-ldap/NGLdap/NGLdapConnection.h b/sope-ldap/NGLdap/NGLdapConnection.h index 3c1bc0d9..527bc9b7 100644 --- a/sope-ldap/NGLdap/NGLdapConnection.h +++ b/sope-ldap/NGLdap/NGLdapConnection.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2005 SKYRIX Software AG + Copyright (C) 2000-2007 SKYRIX Software AG This file is part of SOPE. @@ -34,7 +34,8 @@ void *handle; NSString *hostName; int port; - + unsigned int sizeLimit; + NSTimeInterval timeLimit; NSTimeInterval cacheTimeout; long cacheMaxMemory; /* in bytes */ BOOL isCacheEnabled; @@ -60,6 +61,14 @@ - (BOOL)bindWithMethod:(NSString *)_method binddn:(NSString *)_login credentials:(NSString *)_cred; +/* query parameters */ + +- (void)setQueryTimeLimit:(NSTimeInterval)_timeLimit; +- (NSTimeInterval)queryTimeLimit; + +- (void)setQuerySizeLimit:(unsigned int)_timeLimit; +- (unsigned int )querySizeLimit; + /* running queries */ - (NSEnumerator *)flatSearchAtBaseDN:(NSString *)_base diff --git a/sope-ldap/NGLdap/NGLdapConnection.m b/sope-ldap/NGLdap/NGLdapConnection.m index 1bde62d7..1d0248d5 100644 --- a/sope-ldap/NGLdap/NGLdapConnection.m +++ b/sope-ldap/NGLdap/NGLdapConnection.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2005 SKYRIX Software AG + Copyright (C) 2000-2007 SKYRIX Software AG This file is part of SOPE. @@ -121,7 +121,9 @@ static void freeMods(LDAPMod **mods) { [self setCacheTimeout:120.0]; [self setCacheMaxMemoryUsage:16000]; - + [self setQueryTimeLimit:0.0]; + [self setQuerySizeLimit:0]; + return self; } - (id)initWithHostName:(NSString *)_hostName { @@ -287,6 +289,20 @@ static void freeMods(LDAPMod **mods) { /* running queries */ +- (void)setQueryTimeLimit:(NSTimeInterval)_timeLimit { + self->timeLimit = _timeLimit; +} +- (NSTimeInterval)queryTimeLimit { + return self->timeLimit; +} + +- (void)setQuerySizeLimit:(unsigned int)_sizeLimit { + self->sizeLimit = _sizeLimit; +} +- (unsigned int)querySizeLimit { + return self->sizeLimit; +} + - (NSEnumerator *)_searchAtBaseDN:(NSString *)_base qualifier:(EOQualifier *)_q attributes:(NSArray *)_attributes @@ -321,6 +337,18 @@ static void freeMods(LDAPMod **mods) { __PRETTY_FUNCTION__, [_base cString], [filter cString], [[_attributes description] cString]); } + + /* apply limits */ + + if (self->sizeLimit > 0) + ldap_set_option(self->handle, LDAP_OPT_SIZELIMIT, &(self->sizeLimit)); + + if (self->timeLimit > 0.0) { + int tl = self->timeLimit; /* specified in seconds */ + ldap_set_option(self->handle, LDAP_OPT_TIMELIMIT, &tl); + } + + /* trigger search */ msgid = ldap_search(self->handle, (char *)[_base UTF8String], @@ -336,7 +364,7 @@ static void freeMods(LDAPMod **mods) { /* trouble */ return nil; } - + e = [[NGLdapSearchResultEnumerator alloc] initWithConnection:self messageID:msgid]; diff --git a/sope-ldap/NGLdap/Version b/sope-ldap/NGLdap/Version index 408c1e6c..b764ae62 100644 --- a/sope-ldap/NGLdap/Version +++ b/sope-ldap/NGLdap/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=4 MINOR_VERSION=7 -SUBMINOR_VERSION:=30 +SUBMINOR_VERSION:=31 -- 2.39.5