]> err.no Git - sope/blob - sope-ldap/NGLdap/NGLdapConnection.h
some code cleanups
[sope] / sope-ldap / NGLdap / NGLdapConnection.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGLdapConnection_H__
23 #define __NGLdapConnection_H__
24
25 #import <Foundation/NSObject.h>
26 #import <Foundation/NSDate.h>
27
28 @class NSString, NSArray, NSEnumerator;
29 @class EOQualifier;
30 @class NGLdapEntry;
31
32 @interface NGLdapConnection : NSObject
33 {
34   void           *handle;
35   NSString       *hostName;
36   int            port;
37   
38   NSTimeInterval cacheTimeout;
39   long           cacheMaxMemory; /* in bytes */
40   BOOL           isCacheEnabled;
41
42   struct {
43     BOOL isBound:1;
44   } flags;
45 }
46
47 - (id)initWithHostName:(NSString *)_hostName port:(int)_port; // designated init
48 - (id)initWithHostName:(NSString *)_hostName;
49
50 /* settings */
51
52 - (NSString *)hostName;
53 - (int)port;
54
55 /* binding */
56
57 - (BOOL)isBound;
58 - (void)unbind;
59
60 - (BOOL)bindWithMethod:(NSString *)_method
61   binddn:(NSString *)_login credentials:(NSString *)_cred;
62
63 /* running queries */
64
65 - (NSEnumerator *)flatSearchAtBaseDN:(NSString *)_base
66   qualifier:(EOQualifier *)_q
67   attributes:(NSArray *)_attributes;
68 - (NSEnumerator *)deepSearchAtBaseDN:(NSString *)_base
69   qualifier:(EOQualifier *)_q
70   attributes:(NSArray *)_attributes;
71 - (NSEnumerator *)baseSearchAtBaseDN:(NSString *)_base
72   qualifier:(EOQualifier *)_q
73   attributes:(NSArray *)_attributes;
74
75 - (NGLdapEntry *)entryAtDN:(NSString *)_dn attributes:(NSArray *)_attrs;
76
77 /* cache */
78
79 - (void)setCacheTimeout:(NSTimeInterval)_to;
80 - (NSTimeInterval)cacheTimeout;
81
82 - (void)setCacheMaxMemoryUsage:(long)_maxMem;
83 - (long)cacheMaxMemoryUsage;
84
85 - (void)setUseCache:(BOOL)_flag;
86 - (BOOL)doesUseCache;
87
88 - (void)flushCache;
89 - (void)destroyCache;
90
91 - (void)cacheForgetEntryWithDN:(NSString *)_dn;
92
93 /* modifications */
94
95 - (BOOL)addEntry:(NGLdapEntry *)_entry;
96 - (BOOL)removeEntryWithDN:(NSString *)_dn;
97 - (BOOL)modifyEntryWithDN:(NSString *)_dn changes:(NSArray *)_mods;
98
99 /* root DSE */
100
101 - (NGLdapEntry *)schemaEntry;
102 - (NGLdapEntry *)rootDSE;
103 - (NGLdapEntry *)configEntry;
104 - (NSArray *)namingContexts;
105
106 @end
107
108 @interface NGLdapConnection(PlainPasswordCheck)
109
110 /* specialized password check routine */
111
112 - (NSString *)dnForLogin:(NSString *)_login baseDN:(NSString *)_baseDN;
113
114 + (BOOL)checkPassword:(NSString *)_pwd ofLogin:(NSString *)_login
115   atBaseDN:(NSString *)_baseDN
116   onHost:(NSString *)_hostName port:(int)_port;
117
118 @end
119
120 #endif /* __NGLdapConnection_H__ */