2 $Id: uuidtest.c,v 1.1 2009-02-02 11:55:00 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>
30 #include <atalk/logger.h>
32 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
34 int main( int argc, char **argv)
39 char *uuidstring = NULL;
43 printf("Usage: uuidtest <name> | -u<UUID> [<name> ... | -u<UUID> ...] \n");
47 set_processname("uuidtest");
49 log_setup("uuid.log", log_maxdebug, logtype_default, logoption_cons);
53 printf("Start parsing ldap.conf\n");
54 acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
55 printf("Finished parsing ldap.conf\n");
56 if (ldap_config_valid) {
57 if (ldap_auth_method == LDAP_AUTH_NONE)
58 printf("ldap.conf is ok. Using anonymous bind.\n");
59 else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
60 printf("ldap.conf is ok. Using simple bind.\n");
62 ldap_config_valid = 0;
63 printf("ldap.conf want SASL which is not yet supported.\n");
66 printf("ldap.conf is not ok.\n");
70 for (i=1; i+1 <= argc; i++) {
71 if (STRNCMP("-u", == , argv[i], 2)) {
72 printf("Searching uuid: %s\n", argv[i]+2);
73 uuid_string2bin(argv[i]+2, uuid);
74 ret = getnamefromuuid( uuid, &name, &type);
76 printf("Got user: %s for uuid: %s, type:%d\n", name, argv[i]+2, type);
79 printf("uuid %s not found.\n", argv[i]+2);
81 printf("Searching user: %s\n", argv[i]);
82 ret = getuuidfromname( argv[i], UUID_USER, uuid);
84 uuid_bin2string( uuid, &uuidstring);
85 printf("Got uuid: %s for name: %s, type: USER\n", uuidstring, argv[i]);
88 ret = getuuidfromname( argv[i], UUID_GROUP, uuid);
90 uuid_bin2string( uuid, &uuidstring);
91 printf("Got uuid: %s for name: %s, type: GROUP\n", uuidstring, argv[i]);
95 printf("User %s not found.\n", argv[i]);
103 #endif /* HAVE_NFSv4_ACLS */