2006-08-22 [colin] 2.4.0cvs73
[claws.git] / src / ldapctrl.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2003-2006 Match Grun and the Sylpheed-Claws team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 /*
21  * Functions for LDAP control data.
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #ifdef USE_LDAP
29
30 #include <glib.h>
31 #include <sys/time.h>
32 #include <string.h>
33
34 #include "ldapctrl.h"
35 #include "mgutils.h"
36
37 /**
38  * Create new LDAP control block object.
39  * \return Initialized control object.
40  */
41 LdapControl *ldapctl_create( void ) {
42         LdapControl *ctl;
43
44         ctl = g_new0( LdapControl, 1 );
45         ctl->hostName = NULL;
46         ctl->port = LDAPCTL_DFL_PORT;
47         ctl->baseDN = NULL;
48         ctl->bindDN = NULL;
49         ctl->bindPass = NULL;
50         ctl->listCriteria = NULL;
51         ctl->attribEMail = g_strdup( LDAPCTL_ATTR_EMAIL );
52         ctl->attribCName = g_strdup( LDAPCTL_ATTR_COMMONNAME );
53         ctl->attribFName = g_strdup( LDAPCTL_ATTR_GIVENNAME );
54         ctl->attribLName = g_strdup( LDAPCTL_ATTR_SURNAME );
55         ctl->maxEntries = LDAPCTL_MAX_ENTRIES;
56         ctl->timeOut = LDAPCTL_DFL_TIMEOUT;
57         ctl->maxQueryAge = LDAPCTL_DFL_QUERY_AGE;
58         ctl->matchingOption = LDAPCTL_MATCH_BEGINWITH;
59         ctl->version = 0;
60         ctl->enableTLS = FALSE;
61         ctl->enableSSL = FALSE;
62
63         /* Mutex to protect control block */
64         ctl->mutexCtl = g_malloc0( sizeof( pthread_mutex_t ) );
65         pthread_mutex_init( ctl->mutexCtl, NULL );
66
67         return ctl;
68 }
69
70 /**
71  * Specify hostname to be used.
72  * \param ctl   Control object to process.
73  * \param value Host name.
74  */
75 void ldapctl_set_host( LdapControl* ctl, const gchar *value ) {
76         ctl->hostName = mgu_replace_string( ctl->hostName, value );
77         g_strstrip( ctl->hostName );
78 }
79
80 /**
81  * Specify port to be used.
82  * \param ctl  Control object to process.
83  * \param value Port.
84  */
85 void ldapctl_set_port( LdapControl* ctl, const gint value ) {
86         if( value > 0 ) {
87                 ctl->port = value;
88         }
89         else {
90                 ctl->port = LDAPCTL_DFL_PORT;
91         }
92 }
93
94 /**
95  * Specify base DN to be used.
96  * \param ctl  Control object to process.
97  * \param value Base DN.
98  */
99 void ldapctl_set_base_dn( LdapControl* ctl, const gchar *value ) {
100         ctl->baseDN = mgu_replace_string( ctl->baseDN, value );
101         g_strstrip( ctl->baseDN );
102 }
103
104 /**
105  * Specify bind DN to be used.
106  * \param ctl  Control object to process.
107  * \param value Bind DN.
108  */
109 void ldapctl_set_bind_dn( LdapControl* ctl, const gchar *value ) {
110         ctl->bindDN = mgu_replace_string( ctl->bindDN, value );
111         g_strstrip( ctl->bindDN );
112 }
113
114 /**
115  * Specify bind password to be used.
116  * \param ctl  Control object to process.
117  * \param value Password.
118  */
119 void ldapctl_set_bind_password( LdapControl* ctl, const gchar *value ) {
120         ctl->bindPass = mgu_replace_string( ctl->bindPass, value );
121         g_strstrip( ctl->bindPass );
122 }
123
124 /**
125  * Specify maximum number of entries to retrieve.
126  * \param ctl  Control object to process.
127  * \param value Maximum entries.
128  */
129 void ldapctl_set_max_entries( LdapControl* ctl, const gint value ) {
130         if( value > 0 ) {
131                 ctl->maxEntries = value;
132         }
133         else {
134                 ctl->maxEntries = LDAPCTL_MAX_ENTRIES;
135         }
136 }
137
138 /**
139  * Specify timeout value for LDAP operation (in seconds).
140  * \param ctl  Control object to process.
141  * \param value Timeout.
142  */
143 void ldapctl_set_timeout( LdapControl* ctl, const gint value ) {
144         if( value > 0 ) {
145                 ctl->timeOut = value;
146         }
147         else {
148                 ctl->timeOut = LDAPCTL_DFL_TIMEOUT;
149         }
150 }
151
152 /**
153  * Specify maximum age of query (in seconds) before query is retired.
154  * \param ctl  Control object to process.
155  * \param value Maximum age.
156  */
157 void ldapctl_set_max_query_age( LdapControl* ctl, const gint value ) {
158         if( value > LDAPCTL_MAX_QUERY_AGE ) {
159                 ctl->maxQueryAge = LDAPCTL_MAX_QUERY_AGE;
160         }
161         else if( value < 1 ) {
162                 ctl->maxQueryAge = LDAPCTL_DFL_QUERY_AGE;
163         }
164         else {
165                 ctl->maxQueryAge = value;
166         }
167 }
168
169 /**
170  * Specify matching option to be used for searches.
171  * \param ctl   Control object to process.
172  * \param value Matching option, as follows:
173  * <ul>
174  * <li><code>LDAPCTL_MATCH_BEGINWITH</code> for "begins with" search</li>
175  * <li><code>LDAPCTL_MATCH_CONTAINS</code> for "contains" search</li>
176  * </ul>
177  */
178 void ldapctl_set_matching_option( LdapControl* ctl, const gint value ) {
179         if( value < LDAPCTL_MATCH_BEGINWITH ) {
180                 ctl->matchingOption = LDAPCTL_MATCH_BEGINWITH;
181         }
182         else if( value > LDAPCTL_MATCH_CONTAINS ) {
183                 ctl->matchingOption = LDAPCTL_MATCH_BEGINWITH;
184         }
185         else {
186                 ctl->matchingOption = value;
187         }
188 }
189
190 /**
191  * Specify TLS option.
192  * \param ctl   Control object to process.
193  * \param value <i>TRUE</i> to enable TLS.
194  */
195 void ldapctl_set_tls( LdapControl* ctl, const gboolean value ) {
196         ctl->enableTLS = value;
197 }
198
199 void ldapctl_set_ssl( LdapControl* ctl, const gboolean value ) {
200         ctl->enableSSL = value;
201 }
202
203 /**
204  * Specify search criteria list to be used.
205  * \param ctl   Control data object.
206  * \param value Linked list of LDAP attribute names to use for search.
207  */
208 void ldapctl_set_criteria_list( LdapControl* ctl, GList *value ) {
209         g_return_if_fail( ctl != NULL );
210         mgu_free_dlist( ctl->listCriteria );
211         ctl->listCriteria = value;
212 }
213
214 /**
215  * Return search criteria list.
216  * \param  ctl  Control data object.
217  * \return Linked list of character strings containing LDAP attribute names to
218  *         use for a search. This should not be modified directly. Use the
219  *         <code>ldapctl_set_criteria_list()</code>,
220  *         <code>ldapctl_criteria_list_clear()</code> and
221  *         <code>ldapctl_criteria_list_add()</code> functions for this purpose.
222  */
223 GList *ldapctl_get_criteria_list( const LdapControl* ctl ) {
224         g_return_val_if_fail( ctl != NULL, NULL );
225         return ctl->listCriteria;
226 }
227
228 /**
229  * Clear list of LDAP search attributes.
230  * \param  ctl  Control data object.
231  */
232 void ldapctl_criteria_list_clear( LdapControl *ctl ) {
233         g_return_if_fail( ctl != NULL );
234         mgu_free_dlist( ctl->listCriteria );
235         ctl->listCriteria = NULL;
236 }
237
238 /**
239  * Add LDAP attribute to criteria list.
240  * \param ctl  Control object to process.
241  * \param attr Attribute name to append. If not NULL and unique, a copy will
242  *             be appended to the list.
243  */
244 void ldapctl_criteria_list_add( LdapControl *ctl, gchar *attr ) {
245         g_return_if_fail( ctl != NULL );
246         if( attr != NULL ) {
247                 if( mgu_list_test_unq_nc( ctl->listCriteria, attr ) ) {
248                         ctl->listCriteria = g_list_append(
249                                 ctl->listCriteria, g_strdup( attr ) );
250                 }
251         }
252 }
253
254 /**
255  * Build criteria list using default attributes.
256  * \param ctl  Control object to process.
257  */
258 void ldapctl_default_attributes( LdapControl *ctl ) {
259         g_return_if_fail( ctl != NULL );
260
261         ldapctl_criteria_list_clear( ctl );
262         ldapctl_criteria_list_add( ctl, LDAPCTL_ATTR_COMMONNAME );
263         ldapctl_criteria_list_add( ctl, LDAPCTL_ATTR_GIVENNAME );
264         ldapctl_criteria_list_add( ctl, LDAPCTL_ATTR_SURNAME );
265         ldapctl_criteria_list_add( ctl, LDAPCTL_ATTR_EMAIL );
266 }
267
268 /**
269  * Clear LDAP server member variables.
270  * \param ctl Control object to clear.
271  */
272 void ldapctl_clear( LdapControl *ctl ) {
273         g_return_if_fail( ctl != NULL );
274
275         /* Free internal stuff */
276         g_free( ctl->hostName );
277         g_free( ctl->baseDN );
278         g_free( ctl->bindDN );
279         g_free( ctl->bindPass );
280         g_free( ctl->attribEMail );
281         g_free( ctl->attribCName );
282         g_free( ctl->attribFName );
283         g_free( ctl->attribLName );
284
285         ldapctl_criteria_list_clear( ctl );
286
287         /* Clear pointers */
288         ctl->hostName = NULL;
289         ctl->port = 0;
290         ctl->baseDN = NULL;
291         ctl->bindDN = NULL;
292         ctl->bindPass = NULL;
293         ctl->attribEMail = NULL;
294         ctl->attribCName = NULL;
295         ctl->attribFName = NULL;
296         ctl->attribLName = NULL;
297         ctl->maxEntries = 0;
298         ctl->timeOut = 0;
299         ctl->maxQueryAge = 0;
300         ctl->matchingOption = LDAPCTL_MATCH_BEGINWITH;
301         ctl->version = 0;
302         ctl->enableTLS = FALSE;
303         ctl->enableSSL = FALSE;
304 }
305
306 /**
307  * Free up LDAP server interface object by releasing internal memory.
308  * \param ctl Control object to free.
309  */
310 void ldapctl_free( LdapControl *ctl ) {
311         g_return_if_fail( ctl != NULL );
312
313         /* Free internal stuff */
314         ldapctl_clear( ctl );
315
316         /* Free the mutex */
317         pthread_mutex_destroy( ctl->mutexCtl );
318         g_free( ctl->mutexCtl );
319         ctl->mutexCtl = NULL;
320
321         /* Now release LDAP control object */
322         g_free( ctl );
323 }
324
325 /**
326  * Setup default (empty) values for specified object.
327  * \param ctl  Control object to process.
328  */
329 void ldapctl_default_values( LdapControl *ctl ) {
330         g_return_if_fail( ctl != NULL );
331
332         /* Clear our destination */
333         ldapctl_clear( ctl );
334
335         /* Copy strings */
336         ctl->hostName = g_strdup( "" );
337         ctl->baseDN = g_strdup( "" );
338         ctl->bindDN = g_strdup( "" );
339         ctl->bindPass = g_strdup( "" );
340         ctl->port = LDAPCTL_DFL_PORT;
341         ctl->maxEntries = LDAPCTL_MAX_ENTRIES;
342         ctl->timeOut = LDAPCTL_DFL_TIMEOUT;
343         ctl->maxQueryAge = LDAPCTL_DFL_QUERY_AGE;
344         ctl->matchingOption = LDAPCTL_MATCH_BEGINWITH;
345         ctl->version = 0;
346         ctl->enableTLS = FALSE;
347         ctl->enableSSL = FALSE;
348
349         ldapctl_default_attributes( ctl );
350 }
351
352 /**
353  * Display object to specified stream.
354  * \param ctl    Control object to process.
355  * \param stream Output stream.
356  */
357 void ldapctl_print( const LdapControl *ctl, FILE *stream ) {
358         g_return_if_fail( ctl != NULL );
359
360         pthread_mutex_lock( ctl->mutexCtl );
361         fprintf( stream, "LdapControl:\n" );
362         fprintf( stream, "host name: '%s'\n", ctl->hostName );
363         fprintf( stream, "     port: %d\n",   ctl->port );
364         fprintf( stream, "  base dn: '%s'\n", ctl->baseDN );
365         fprintf( stream, "  bind dn: '%s'\n", ctl->bindDN );
366         fprintf( stream, "bind pass: '%s'\n", ctl->bindPass );
367         fprintf( stream, "attr mail: '%s'\n", ctl->attribEMail );
368         fprintf( stream, "attr comn: '%s'\n", ctl->attribCName );
369         fprintf( stream, "attr frst: '%s'\n", ctl->attribFName );
370         fprintf( stream, "attr last: '%s'\n", ctl->attribLName );
371         fprintf( stream, "max entry: %d\n",   ctl->maxEntries );
372         fprintf( stream, "  timeout: %d\n",   ctl->timeOut );
373         fprintf( stream, "  max age: %d\n",   ctl->maxQueryAge );
374         fprintf( stream, "match opt: %d\n",   ctl->matchingOption );
375         fprintf( stream, "  version: %d\n",   ctl->version );
376         fprintf( stream, "      TLS: %s\n",   ctl->enableTLS ? "yes" : "no" );
377         fprintf( stream, "      SSL: %s\n",   ctl->enableSSL ? "yes" : "no" );
378         fprintf( stream, "crit list:\n" );
379         if( ctl->listCriteria ) {
380                 mgu_print_dlist( ctl->listCriteria, stream );
381         }
382         else {
383                 fprintf( stream, "\t!!!none!!!\n" );
384         }
385         pthread_mutex_unlock( ctl->mutexCtl );
386 }
387
388 /**
389  * Copy member variables to specified object. Mutex lock object is
390  * not copied.
391  * \param ctlFrom Object to copy from.
392  * \param ctlTo   Destination object.
393  */
394 void ldapctl_copy( const LdapControl *ctlFrom, LdapControl *ctlTo ) {
395         GList *node;
396
397         g_return_if_fail( ctlFrom != NULL );
398         g_return_if_fail( ctlTo != NULL );
399
400         /* Lock both objects */
401         pthread_mutex_lock( ctlFrom->mutexCtl );
402         pthread_mutex_lock( ctlTo->mutexCtl );
403
404         /* Clear our destination */
405         ldapctl_clear( ctlTo );
406
407         /* Copy strings */
408         ctlTo->hostName = g_strdup( ctlFrom->hostName );
409         ctlTo->baseDN = g_strdup( ctlFrom->baseDN );
410         ctlTo->bindDN = g_strdup( ctlFrom->bindDN );
411         ctlTo->bindPass = g_strdup( ctlFrom->bindPass );
412         ctlTo->attribEMail = g_strdup( ctlFrom->attribEMail );
413         ctlTo->attribCName = g_strdup( ctlFrom->attribCName );
414         ctlTo->attribFName = g_strdup( ctlFrom->attribFName );
415         ctlTo->attribLName = g_strdup( ctlFrom->attribLName );
416
417         /* Copy search criteria */
418         node = ctlFrom->listCriteria;
419         while( node ) {
420                 ctlTo->listCriteria = g_list_append(
421                         ctlTo->listCriteria, g_strdup( node->data ) );
422                 node = g_list_next( node );
423         }
424
425         /* Copy other members */
426         ctlTo->port = ctlFrom->port;
427         ctlTo->maxEntries = ctlFrom->maxEntries;
428         ctlTo->timeOut = ctlFrom->timeOut;
429         ctlTo->maxQueryAge = ctlFrom->maxQueryAge;
430         ctlTo->matchingOption = ctlFrom->matchingOption;
431         ctlTo->version = ctlFrom->version;
432         ctlTo->enableTLS = ctlFrom->enableTLS;
433         ctlTo->enableSSL = ctlFrom->enableSSL;
434
435         /* Unlock */
436         pthread_mutex_unlock( ctlTo->mutexCtl );
437         pthread_mutex_unlock( ctlFrom->mutexCtl );
438 }
439
440 /**
441  * Search criteria fragment - two terms - begin with (default).
442  */
443 static gchar *_criteria2BeginWith = "(&(givenName=%s*)(sn=%s*))";
444
445 /**
446  * Search criteria fragment - two terms - contains.
447  */
448 static gchar *_criteria2Contains  = "(&(givenName=*%s*)(sn=*%s*))";
449
450 /**
451  * Create an LDAP search criteria by parsing specified search term. The search
452  * term may contain two names separated by the first embedded space found in
453  * the search term. It is assumed that the two tokens are first name and last
454  * name, or vice versa. An appropriate search criteria will be constructed.
455  *
456  * \param  searchTerm   Reference to search term to process.
457  * \param  matchOption  Set to the following:
458  * <ul>
459  * <li><code>LDAPCTL_MATCH_BEGINWITH</code> for "begins with" search</li>
460  * <li><code>LDAPCTL_MATCH_CONTAINS</code> for "contains" search</li>
461  * </ul>
462  *
463  * \return Formatted search criteria, or <code>NULL</code> if there is no
464  *         embedded spaces. The search term should be g_free() when no
465  *         longer required.
466  */
467 static gchar *ldapctl_build_ldap_criteria(
468                 const gchar *searchTerm, const gint matchOption )
469 {
470         gchar *p;
471         gchar *t1;
472         gchar *t2 = NULL;
473         gchar *term;
474         gchar *crit = NULL;
475         gchar *criteriaFmt;
476
477         if( matchOption == LDAPCTL_MATCH_CONTAINS ) {
478                 criteriaFmt = _criteria2Contains;
479         }
480         else {
481                 criteriaFmt = _criteria2BeginWith;
482         }
483
484         term = g_strdup( searchTerm );
485         g_strstrip( term );
486
487         /* Find first space character */        
488         t1 = p = term;
489         while( *p ) {
490                 if( *p == ' ' ) {
491                         *p = '\0';
492                         t2 = g_strdup( 1 + p );
493                         break;
494                 }
495                 p++;
496         }
497
498         if( t2 ) {
499                 /* Format search criteria */
500                 gchar *p1, *p2;
501
502                 g_strstrip( t2 );
503                 p1 = g_strdup_printf( criteriaFmt, t1, t2 );
504                 p2 = g_strdup_printf( criteriaFmt, t2, t1 );
505                 crit = g_strdup_printf( "(&(|%s%s)(mail=*))", p1, p2 );
506
507                 g_free( t2 );
508                 g_free( p1 );
509                 g_free( p2 );
510         }
511         g_free( term );
512         return crit;
513 }
514
515
516 /**
517  * Search criteria fragment - single term - begin with (default).
518  */
519 static gchar *_criteriaBeginWith = "(%s=%s*)";
520
521 /**
522  * Search criteria fragment - single term - contains.
523  */
524 static gchar *_criteriaContains  = "(%s=*%s*)";
525
526 /**
527  * Build a formatted LDAP search criteria string from criteria list.
528  * \param ctl  Control object to process.
529  * \param searchVal Value to search for.
530  * \return Formatted string. Should be g_free() when done.
531  */
532 gchar *ldapctl_format_criteria( LdapControl *ctl, const gchar *searchVal ) {
533         GList *node;
534         gchar *p1, *p2, *retVal;
535         gchar *criteriaFmt;
536
537         g_return_val_if_fail( ctl != NULL, NULL );
538         g_return_val_if_fail( searchVal != NULL, NULL );
539
540         /* Test whether there are more that one search terms */
541         retVal = ldapctl_build_ldap_criteria( searchVal, ctl->matchingOption );
542         if( retVal ) return retVal;
543
544         if( ctl->matchingOption ==  LDAPCTL_MATCH_CONTAINS ) {
545                 criteriaFmt = _criteriaContains;
546         }
547         else {
548                 criteriaFmt = _criteriaBeginWith;
549         }
550
551         /* No - just a simple search */
552         /* p1 contains previous formatted criteria */
553         /* p2 contains next formatted criteria */
554         retVal = p1 = p2 = NULL;
555         node = ctl->listCriteria;
556         while( node ) {
557                 gchar *attr, *tmp;
558
559                 attr = node->data;
560                 node = g_list_next( node );
561
562                 /* Switch pointers */
563                 tmp = p1; p1 = p2; p2 = tmp;
564
565                 if( p1 ) {
566                         /* Subsequent time through */
567                         gchar *crit;
568
569                         /* Format query criteria */
570                         crit = g_strdup_printf( criteriaFmt, attr, searchVal );
571
572                         /* Append to existing criteria */                       
573                         g_free( p2 );
574                         p2 = g_strdup_printf( "(|%s%s)", p1, crit );
575
576                         g_free( crit );
577                 }
578                 else {
579                         /* First time through - Format query criteria */
580                         p2 = g_strdup_printf( criteriaFmt, attr, searchVal );
581                 }
582         }
583
584         if( p2 == NULL ) {
585                 /* Nothing processed - format a default attribute */
586                 retVal = g_strdup_printf( "(%s=*)", LDAPCTL_ATTR_EMAIL );
587         }
588         else {
589                 /* We have something - free up previous result */
590                 retVal = p2;
591                 g_free( p1 );
592         }
593         return retVal;
594 }
595
596 /**
597  * Return array of pointers to attributes for LDAP query.
598  * \param  ctl  Control object to process.
599  * \return NULL terminated list.
600  */
601 char **ldapctl_attribute_array( LdapControl *ctl ) {
602         char **ptrArray;
603         GList *node;
604         gint cnt, i;
605         g_return_val_if_fail( ctl != NULL, NULL );
606
607         cnt = g_list_length( ctl->listCriteria );
608         ptrArray = g_new0( char *, 1 + cnt );
609         i = 0;
610         node = ctl->listCriteria;
611         while( node ) {
612                 ptrArray[ i++ ] = node->data;
613                 node = g_list_next( node );
614         }
615         ptrArray[ i ] = NULL;
616         return ptrArray;
617 }
618
619 /**
620  * Free array of pointers allocated by ldapctl_criteria_array().
621  * param ptrArray Array to clear.
622  */
623 void ldapctl_free_attribute_array( char **ptrArray ) {
624         gint i;
625
626         /* Clear array to NULL's */
627         for( i = 0; ptrArray[i] != NULL; i++ ) {
628                 ptrArray[i] = NULL;
629         }
630         g_free( ptrArray );
631 }       
632
633 /**
634  * Parse LDAP search string, building list of LDAP criteria attributes. This
635  * may be used to convert an old style Sylpheed LDAP search criteria to the
636  * new format. The old style uses a standard LDAP search string, for example:
637  * <pre>
638  *    (&(mail=*)(cn=%s*))
639  * </pre>
640  * This function extracts the two LDAP attributes <code>mail</code> and
641  * <code>cn</code>, adding each to a list.
642  *
643  * \param ctl Control object to process.
644  * \param criteria LDAP search criteria string.
645  */
646 void ldapctl_parse_ldap_search( LdapControl *ctl, gchar *criteria ) {
647         gchar *ptr;
648         gchar *pFrom;
649         gchar *attrib;
650         gint iLen;
651
652         g_return_if_fail( ctl != NULL );
653
654         ldapctl_criteria_list_clear( ctl );
655         if( criteria == NULL ) return;
656
657         pFrom = NULL;
658         ptr = criteria;
659         while( *ptr ) {
660                 if( *ptr == '(' ) {
661                         pFrom = 1 + ptr;
662                 }
663                 if( *ptr == '=' ) {
664                         if( pFrom ) {
665                                 iLen = ptr - pFrom;
666                                 attrib = g_strndup( pFrom, iLen );
667                                 g_strstrip( attrib );
668                                 ldapctl_criteria_list_add( ctl, attrib );
669                                 g_free( attrib );
670                         }
671                         pFrom = NULL;
672                 }
673                 ptr++;
674         }
675 }
676
677 #endif  /* USE_LDAP */
678
679 /*
680  * End of Source.
681  */
682