Obtains a user's fully distinguished object name from the Census and copies it into the buffer supplied by the caller.
#include <ascauth.h>
int ASC_GETCONTEXT(ASCENV *asce, char *user, char *buffer, u_int size);
Returns one of the following integer values defined in ascauth.h:
The buffer is padded with nulls if needed.
The format of the returned login context is the simple dot form. For example: .jondoe.j.myorg
#include <stdio.h> #include <stdlib.h> #include <ascauth.h> #define MAX_CONTEXT 512 main(int argc, char *argv[]) { ASCENV *asce; char *user, *context; int rc; if (argc != 2) { fprintf(stderr, "usage: %s <user>\n", argv[0]); exit(EXIT_FAILURE); } user = argv[1]; /* allocate buffer */ context = (char *) malloc(MAX_CONTEXT); /* initialize the authentication environment */ asce = ASC_INIT(NULL); if (asce == NULL) { fprintf(stderr, "Error: cannot initialize authentication environment\n"); exit(EXIT_FAILURE); } /* get the user's context */ rc = ASC_GETCONTEXT(asce, user, context, MAX_CONTEXT); if (rc == AS_OK) printf("context is %s\n", context); else printf("RC=%d, %s", rc, ASC_STRERROR(rc)); free(context); /* now terminate the authentication environment */ ASC_TERM(asce); return 0; }