2 Copyright (c) 2008,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 */
26 #define LDAP_DEPRECATED 1
30 #include <atalk/ldapconfig.h>
31 #include <atalk/uuid.h>
32 #include <atalk/logger.h>
33 #include <atalk/iniparser.h>
35 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
39 printf("Usage: afpldaptest -u <user> | -g <group> | -i <UUID>\n");
42 static void parse_ldapconf()
44 static int inited = 0;
45 dictionary *iniconfig;
50 printf("Start parsing afp.conf\n");
51 iniconfig = atalk_iniparser_load(_PATH_CONFDIR "afp.conf");
52 acl_ldap_readconfig(iniconfig);
53 printf("Finished parsing afp.conf\n");
54 if (ldap_config_valid) {
55 if (ldap_auth_method == LDAP_AUTH_NONE)
56 printf("afp.conf is ok. Using anonymous bind.\n");
57 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
58 printf("afp.conf is ok. Using simple bind.\n");
60 ldap_config_valid = 0;
61 printf("afp.conf wants SASL which is not yet supported.\n");
65 printf("afp.conf is not ok, not using LDAP. Only local UUID testing available.\n");
68 printf("Built without LDAP support, only local UUID testing available.\n");
74 int main( int argc, char **argv)
83 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
89 setuplog("default:maxdebug", "/dev/tty");
96 setuplog("default:info", "/dev/tty");
98 printf("Searching user: %s\n", optarg);
99 ret = getuuidfromname( optarg, UUID_USER, uuid);
101 printf("User: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
103 printf("User %s not found.\n", optarg);
109 setuplog("default:info", "/dev/tty");
111 printf("Searching group: %s\n", optarg);
112 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
114 printf("Group: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
116 printf("Group %s not found.\n", optarg);
122 setuplog("default:info", "/dev/tty");
124 printf("Searching uuid: %s\n", optarg);
125 uuid_string2bin(optarg, uuid);
126 ret = getnamefromuuid( uuid, &name, &type);
130 printf("UUID: %s ==> User: %s\n", optarg, name);
133 printf("UUID: %s ==> Group: %s\n", optarg, name);
136 printf("???: %s\n", optarg);
141 printf("UUID: %s not found.\n", optarg);