2 $Id: uuidtest.c,v 1.4 2009-11-27 15:50:26 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
28 #include <atalk/ldapconfig.h>
29 #include <atalk/uuid.h>
31 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
33 int main( int argc, char **argv)
38 char *uuidstring = NULL;
42 printf("Usage: uuidtest <name> | -u<UUID> [<name> ... | -u<UUID> ...] \n");
46 /* Parse afp_ldap.conf */
47 printf("Start parsing afp_ldap.conf\n");
48 acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
49 printf("Finished parsing afp_ldap.conf\n");
50 if (ldap_config_valid) {
51 if (ldap_auth_method == LDAP_AUTH_NONE)
52 printf("afp_ldap.conf is ok. Using anonymous bind.\n");
53 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
54 printf("afp_ldap.conf is ok. Using simple bind.\n");
56 ldap_config_valid = 0;
57 printf("afp_ldap.conf want SASL which is not yet supported.\n");
60 printf("afp_ldap.conf is not ok.\n");
64 for (i=1; i+1 <= argc; i++) {
65 if (STRNCMP("-u", == , argv[i], 2)) {
66 printf("Searching uuid: %s\n", argv[i]+2);
67 uuid_string2bin(argv[i]+2, uuid);
68 ret = getnamefromuuid( uuid, &name, &type);
70 printf("Got user: %s for uuid: %s, type:%d\n", name, argv[i]+2, type);
73 printf("uuid %s not found.\n", argv[i]+2);
75 printf("Searching user: %s\n", argv[i]);
76 ret = getuuidfromname( argv[i], UUID_USER, uuid);
78 uuid_bin2string( uuid, &uuidstring);
79 printf("Got uuid: %s for name: %s, type: USER\n", uuidstring, argv[i]);
82 ret = getuuidfromname( argv[i], UUID_GROUP, uuid);
84 uuid_bin2string( uuid, &uuidstring);
85 printf("Got uuid: %s for name: %s, type: GROUP\n", uuidstring, argv[i]);
89 printf("User %s not found.\n", argv[i]);
97 #endif /* HAVE_NFSv4_ACLS */