1 /* 2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client 3 * Copyright (C) 2003-2012 Match Grun and the Claws Mail 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 3 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, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 /* 21 * Functions for LDAP control data. 22 */ 23 24 #ifndef __LDAPCTRL_H__ 25 #define __LDAPCTRL_H__ 26 27 #ifdef USE_LDAP 28 29 #include <glib.h> 30 #include <stdio.h> 31 #include <pthread.h> 32 33 /* 34 * Constants. 35 */ 36 #define LDAPCTL_DFL_PORT 389 37 #define LDAPCTL_DFL_SSL_PORT 636 38 #define LDAPCTL_MAX_ENTRIES 30 39 #define LDAPCTL_DFL_TIMEOUT 30 40 #define LDAPCTL_DFL_QUERY_AGE 600 41 #define LDAPCTL_MAX_QUERY_AGE 86400 42 43 #define LDAPCTL_ATTR_EMAIL "mail" 44 #define LDAPCTL_ATTR_COMMONNAME "cn" 45 #define LDAPCTL_ATTR_GIVENNAME "givenName" 46 #define LDAPCTL_ATTR_SURNAME "sn" 47 #define LDAPCTL_ATTR_PHONE "telephoneNumber" 48 #define LDAPCTL_ATTR_DISPLAYNAME "displayName" 49 50 #define LDAPCTL_DFL_ATTR_LIST "mail, cn, givenName, sn, displayName" 51 52 /* 53 * Search matching options. 54 */ 55 #define LDAPCTL_MATCH_BEGINWITH 0 56 #define LDAPCTL_MATCH_CONTAINS 1 57 58 /* 59 * Data structures. 60 */ 61 typedef struct _LdapControl LdapControl; 62 struct _LdapControl { 63 gchar *hostName; 64 gint port; 65 gchar *baseDN; 66 gchar *bindDN; 67 gint maxEntries; 68 gint timeOut; 69 gint maxQueryAge; 70 gint matchingOption; 71 gint version; 72 gboolean enableTLS; 73 gboolean enableSSL; 74 gchar *attribEMail; 75 gchar *attribCName; 76 gchar *attribFName; 77 gchar *attribLName; 78 gchar *attribDName; 79 GList *listCriteria; 80 pthread_mutex_t *mutexCtl; 81 }; 82 83 /* Function prototypes */ 84 LdapControl *ldapctl_create ( void ); 85 void ldapctl_set_host ( LdapControl* ctl, const gchar *value ); 86 void ldapctl_set_port ( LdapControl* ctl, const gint value ); 87 void ldapctl_set_base_dn ( LdapControl* ctl, const gchar *value ); 88 void ldapctl_set_bind_dn ( LdapControl* ctl, const gchar *value ); 89 void ldapctl_set_bind_password 90 ( LdapControl* ctl, const gchar *value, gboolean encrypt, gboolean change ); 91 gchar* ldapctl_get_bind_password ( LdapControl* ctl ); 92 void ldapctl_set_max_entries ( LdapControl* ctl, const gint value ); 93 void ldapctl_set_timeout ( LdapControl* ctl, const gint value ); 94 void ldapctl_set_max_query_age ( LdapControl* ctl, const gint value ); 95 void ldapctl_set_matching_option( LdapControl* ctl, const gint value ); 96 void ldapctl_set_tls ( LdapControl* ctl, const gboolean value ); 97 void ldapctl_set_ssl ( LdapControl* ctl, const gboolean value ); 98 GList *ldapctl_get_criteria_list( const LdapControl* ctl ); 99 void ldapctl_criteria_list_clear( LdapControl *ctl ); 100 void ldapctl_criteria_list_add ( LdapControl *ctl, gchar *attr ); 101 void ldapctl_free ( LdapControl *ctl ); 102 void ldapctl_print ( const LdapControl *ctl, FILE *stream ); 103 void ldapctl_copy ( const LdapControl *ctlFrom, 104 LdapControl *ctlTo ); 105 gchar *ldapctl_format_criteria ( LdapControl *ctl, const gchar *searchVal ); 106 char **ldapctl_attribute_array ( LdapControl *ctl ); 107 char **ldapctl_full_attribute_array( LdapControl *ctl ); 108 void ldapctl_free_attribute_array( char **ptrArray ); 109 void ldapctl_parse_ldap_search ( LdapControl *ctl, gchar *criteria ); 110 gchar *ldapctl_get_default_criteria(void); 111 GList *ldapctl_get_default_criteria_list(); 112 gboolean ldapctl_compare_list(GList *l1, GList *l2); 113 114 #endif /* USE_LDAP */ 115 116 #endif /* __LDAPCTRL_H__ */ 117 118