2 Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
17 #endif /* HAVE_CONFIG_H */
28 #include <atalk/ldapconfig.h>
29 #include <atalk/logger.h>
30 #include <atalk/iniparser.h>
32 int acl_ldap_readconfig(dictionary *iniconfig)
38 /* now see if its a correct pref */
39 for (i = 0; ldap_prefs[i].name != NULL; i++) {
40 if ((val = iniparser_getstring(ldap_prefs[i].name)) != NULL) {
41 /* ok, found a valid pref */
43 /* check if we have pre-defined values */
44 if (ldap_prefs[i].intfromarray == 0) {
45 /* no, its just a string */
46 ldap_prefs[i].valid = 0;
47 if (ldap_prefs[i].strorint)
49 *((int *)(ldap_prefs[i].pref)) = atoi(val);
51 /* store string as string */
52 *((char **)(ldap_prefs[i].pref)) = val;
54 /* ok, we have string to int mapping for this pref
55 eg. "none", "simple", "sasl" map to 0, 128, 129 */
56 for (j = 0; prefs_array[j].pref != NULL; j++) {
57 if ((strcmp(prefs_array[j].pref, ldap_prefs[i].name) == 0)
58 && (strcmp(prefs_array[j].valuestring, val) == 0)) {
59 ldap_prefs[i].valid = 0;
60 *((int *)(ldap_prefs[i].pref)) = prefs_array[j].value;
68 /* check if the config is sane and complete */
70 ldap_config_valid = 1;
72 while(ldap_prefs[i].pref != NULL) {
73 if ( ldap_prefs[i].valid != 0) {
74 LOG(log_debug, logtype_afpd,"afp_ldap.conf: Missing option: \"%s\"", ldap_prefs[i].name);
75 ldap_config_valid = 0;
81 if (ldap_config_valid) {
82 if (ldap_auth_method == LDAP_AUTH_NONE)
83 LOG(log_debug, logtype_afpd,"afp_ldap.conf: Using anonymous bind.");
84 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
85 LOG(log_debug, logtype_afpd,"afp_ldap.conf: Using simple bind.");
87 ldap_config_valid = 0;
88 LOG(log_error, logtype_afpd,"afp_ldap.conf: SASL not yet supported.");
91 LOG(log_info, logtype_afpd,"afp_ldap.conf: not used");
95 #endif /* HAVE_LDAP */