-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicsf_destroy_object.c
45 lines (36 loc) · 1002 Bytes
/
icsf_destroy_object.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "icsf.h"
#include "log.h"
#include "util.h"
int main(int argc, char *argv[])
{
int rc = 0;
LDAP *ld = NULL;
char *uri, *dn, *pw;
struct icsf_object_record obj;
if (argc != 4) {
printf("Usage: %s <token name> <sequence> [S|T]\n", base_name(argv[0]));
return 1;
}
snprintf(obj.token_name, sizeof(obj.token_name), "%s", argv[1]);
obj.sequence = (unsigned long) atoll(argv[2]);
obj.id = (char) toupper(*argv[3]);
init_conn_data(&uri, &dn, &pw);
OCK_LOG_DEBUG("Logging in\n");
if ((rc = icsf_login(&ld, uri, dn, pw)))
goto cleanup;
OCK_LOG_DEBUG("Checking support\n");
if ((rc = icsf_check_pkcs_extension(ld)))
goto cleanup;
OCK_LOG_DEBUG("Destroying token\n");
if ((rc = icsf_destroy_object(ld, NULL, &obj)))
goto cleanup;
cleanup:
if (rc)
printf("Error!\n");
if (ld)
icsf_logout(ld);
return rc;
}