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>
34 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
38 printf("Usage: afpldaptest -u <user> | -g <group> | -i <UUID>\n");
41 static void parse_ldapconf()
43 static int inited = 0;
47 /* Parse afp_ldap.conf */
48 printf("Start parsing afp_ldap.conf\n");
49 acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
50 printf("Finished parsing afp_ldap.conf\n");
51 if (ldap_config_valid) {
52 if (ldap_auth_method == LDAP_AUTH_NONE)
53 printf("afp_ldap.conf is ok. Using anonymous bind.\n");
54 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
55 printf("afp_ldap.conf is ok. Using simple bind.\n");
57 ldap_config_valid = 0;
58 printf("afp_ldap.conf wants SASL which is not yet supported.\n");
62 printf("afp_ldap.conf is not ok, not using LDAP. Only local UUID testing available.\n");
65 printf("Built without LDAP support, only local UUID testing available.\n");
71 int main( int argc, char **argv)
80 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
86 setuplog("default log_maxdebug /dev/tty");
93 setuplog("default log_info /dev/tty");
95 printf("Searching user: %s\n", optarg);
96 ret = getuuidfromname( optarg, UUID_USER, uuid);
98 printf("User: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
100 printf("User %s not found.\n", optarg);
106 setuplog("default log_info /dev/tty");
108 printf("Searching group: %s\n", optarg);
109 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
111 printf("Group: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
113 printf("Group %s not found.\n", optarg);
119 setuplog("default log_info /dev/tty");
121 printf("Searching uuid: %s\n", optarg);
122 uuid_string2bin(optarg, uuid);
123 ret = getnamefromuuid( uuid, &name, &type);
127 printf("local UUID: %s\n", optarg);
130 printf("UUID: %s ==> User: %s\n", optarg, name);
133 printf("UUID: %s ==> Group: %s\n", optarg, name);
138 printf("UUID: %s not found.\n", optarg);