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 */
28 #include <atalk/ldapconfig.h>
29 #include <atalk/uuid.h>
30 #include <atalk/logger.h>
32 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
36 printf("Usage: afpldaptest -u <user> | -g <group> | -i <UUID>\n");
39 static void parse_ldapconf()
41 static int inited = 0;
44 /* Parse afp_ldap.conf */
45 printf("Start parsing afp_ldap.conf\n");
46 acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
47 printf("Finished parsing afp_ldap.conf\n");
48 if (ldap_config_valid) {
49 if (ldap_auth_method == LDAP_AUTH_NONE)
50 printf("afp_ldap.conf is ok. Using anonymous bind.\n");
51 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
52 printf("afp_ldap.conf is ok. Using simple bind.\n");
54 ldap_config_valid = 0;
55 printf("afp_ldap.conf wants SASL which is not yet supported.\n");
59 printf("afp_ldap.conf is not ok, not using LDAP. Only local UUID testing available.\n");
65 int main( int argc, char **argv)
74 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
80 setuplog("default log_maxdebug /dev/tty");
87 setuplog("default log_info /dev/tty");
89 printf("Searching user: %s\n", optarg);
90 ret = getuuidfromname( optarg, UUID_USER, uuid);
92 printf("User: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
94 printf("User %s not found.\n", optarg);
100 setuplog("default log_info /dev/tty");
102 printf("Searching group: %s\n", optarg);
103 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
105 printf("Group: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
107 printf("Group %s not found.\n", optarg);
113 setuplog("default log_info /dev/tty");
115 printf("Searching uuid: %s\n", optarg);
116 uuid_string2bin(optarg, uuid);
117 ret = getnamefromuuid( uuid, &name, &type);
121 printf("local UUID: %s\n", optarg);
124 printf("UUID: %s ==> User: %s\n", optarg, name);
127 printf("UUID: %s ==> Group: %s\n", optarg, name);
132 printf("UUID: %s not found.\n", optarg);
147 #endif /* HAVE_ACLS */