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;
44 dictionary *iniconfig;
48 /* Parse afp_ldap.conf */
49 printf("Start parsing afp_ldap.conf\n");
50 iniconfig = iniparser_load(_PATH_CONFDIR "afp.conf");
51 acl_ldap_readconfig(iniconfig);
52 printf("Finished parsing afp_ldap.conf\n");
53 if (ldap_config_valid) {
54 if (ldap_auth_method == LDAP_AUTH_NONE)
55 printf("afp_ldap.conf is ok. Using anonymous bind.\n");
56 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
57 printf("afp_ldap.conf is ok. Using simple bind.\n");
59 ldap_config_valid = 0;
60 printf("afp_ldap.conf wants SASL which is not yet supported.\n");
64 printf("afp_ldap.conf is not ok, not using LDAP. Only local UUID testing available.\n");
67 printf("Built without LDAP support, only local UUID testing available.\n");
73 int main( int argc, char **argv)
82 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
88 setuplog("default:maxdebug", "/dev/tty");
95 setuplog("default:info", "/dev/tty");
97 printf("Searching user: %s\n", optarg);
98 ret = getuuidfromname( optarg, UUID_USER, uuid);
100 printf("User: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
102 printf("User %s not found.\n", optarg);
108 setuplog("default:info", "/dev/tty");
110 printf("Searching group: %s\n", optarg);
111 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
113 printf("Group: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid));
115 printf("Group %s not found.\n", optarg);
121 setuplog("default:info", "/dev/tty");
123 printf("Searching uuid: %s\n", optarg);
124 uuid_string2bin(optarg, uuid);
125 ret = getnamefromuuid( uuid, &name, &type);
129 printf("UUID: %s ==> User: %s\n", optarg, name);
132 printf("UUID: %s ==> Group: %s\n", optarg, name);
135 printf("???: %s\n", optarg);
140 printf("UUID: %s not found.\n", optarg);