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 */
20 #ifdef HAVE_NFSv4_ACLS
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)
73 char *uuidstring = NULL;
76 setuplog("console log_error /dev/tty");
78 while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
84 setuplog("console log_debug /dev/tty");
90 printf("Searching user: %s\n", optarg);
91 ret = getuuidfromname( optarg, UUID_USER, uuid);
93 uuid_bin2string( uuid, &uuidstring);
94 printf("User: %s ==> UUID: %s\n", optarg, uuidstring);
97 printf("User %s not found.\n", optarg);
103 printf("Searching group: %s\n", optarg);
104 ret = getuuidfromname( optarg, UUID_GROUP, uuid);
106 uuid_bin2string( uuid, &uuidstring);
107 printf("Group: %s ==> UUID: %s\n", optarg, uuidstring);
110 printf("Group %s not found.\n", optarg);
116 printf("Searching uuid: %s\n", optarg);
117 uuid_string2bin(optarg, uuid);
118 ret = getnamefromuuid( uuid, &name, &type);
120 if (type == UUID_USER)
121 printf("UUID: %s ==> User: %s\n", optarg, name);
123 printf("UUID: %s ==> Group: %s\n", optarg, name);
126 printf("UUID: %s not found.\n", optarg);
141 #endif /* HAVE_NFSv4_ACLS */