2 $Id: uuidtest.c,v 1.3 2009-11-28 12:27:24 franklahm Exp $
3 Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
18 #endif /* HAVE_CONFIG_H */
29 #include <atalk/ldapconfig.h>
30 #include <atalk/uuid.h>
31 #include <atalk/logger.h>
33 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
37 printf("Usage: afpldaptest -u <user> | -g <group> | -i <UUID>\n");
40 static void parse_ldapconf()
42 static int inited = 0;
45 /* Parse afp_ldap.conf */
46 printf("Start parsing afp_ldap.conf\n");
47 acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
48 printf("Finished parsing afp_ldap.conf\n");
49 if (ldap_config_valid) {
50 if (ldap_auth_method == LDAP_AUTH_NONE)
51 printf("afp_ldap.conf is ok. Using anonymous bind.\n");
52 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
53 printf("afp_ldap.conf is ok. Using simple bind.\n");
55 ldap_config_valid = 0;
56 printf("afp_ldap.conf wants SASL which is not yet supported.\n");
60 printf("afp_ldap.conf is not ok.\n");
67 int main( int argc, char **argv)
74 char *uuidstring = NULL;
77 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
83 setuplog("default log_maxdebug /dev/tty");
90 setuplog("default log_info /dev/tty");
92 printf("Searching user: %s\n", optarg);
93 ret = getuuidfromname( optarg, UUID_USER, uuid);
95 uuid_bin2string( uuid, &uuidstring);
96 printf("User: %s ==> UUID: %s\n", optarg, uuidstring);
99 printf("User %s not found.\n", optarg);
105 setuplog("default log_info /dev/tty");
107 printf("Searching group: %s\n", optarg);
108 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
110 uuid_bin2string( uuid, &uuidstring);
111 printf("Group: %s ==> UUID: %s\n", optarg, uuidstring);
114 printf("Group %s not found.\n", optarg);
120 setuplog("default log_info /dev/tty");
122 printf("Searching uuid: %s\n", optarg);
123 uuid_string2bin(optarg, uuid);
124 ret = getnamefromuuid( uuid, &name, &type);
126 if (type == UUID_USER)
127 printf("UUID: %s ==> User: %s\n", optarg, name);
129 printf("UUID: %s ==> Group: %s\n", optarg, name);
132 printf("UUID: %s not found.\n", optarg);
147 #endif /* HAVE_ACLS */