Verifies the password of a user.
#include <ascauth.h>
int ASC_CHKPASSWD(ASCENV *asce, char *user, char *pass, ASCUSER *ascu);
Returns one of the following integer values defined in ascauth.h:
If an AS_OK return code is returned, the following fields in the ASCUSER structure contain additional information about the authenticated user:
If an AS_REVOKED code is returned, the following field in the ASCUSER structure contains additional information about the user:
#include <stdio.h> #include <stdlib.h> #include <ascauth.h> main(int argc, char *argv[]) { ASCENV *asce; ASCUSER ascu; char *user, *pass; int rc; if (argc != 3) { fprintf(stderr, "usage: %s <user> <password>\n", argv[0]); exit(EXIT_FAILURE); } user = argv[1]; pass = argv[2]; /* initialize the authentication environment */ asce = ASC_INIT(NULL); if (asce == NULL) { fprintf(stderr, "Error: cannot initialize authentication environment\n"); exit(EXIT_FAILURE); } /* check the user's password */ rc = ASC_CHKPASSWD(asce, user, pass, &ascu); if (rc == AS_OK) printf("password ok\n"); else if (rc == AS_NO) printf("password invalid\n"); else printf("RC=%d, %s", rc, ASC_STRERROR(rc)); /* now terminate the authentication environment */ ASC_TERM(asce); return 0; }