Changes the password of a user.
#include <ascauth.h>
int ASC_CHGPASSWD(ASCENV *asce, char *user, char *oldpass, char *newpass);
Returns one of the following integer values defined in ascauth.h:
#include <stdio.h> #include <stdlib.h> #include <ascauth.h> main(int argc, char *argv[]) { ASCENV *asce; ASCUSER ascu; char *user, *oldpass, *newpass; int rc; if (argc != 4) { fprintf(stderr, "usage: %s <user> <oldpass> <newpass>\n", argv[0]); exit(EXIT_FAILURE); } user = argv[1]; oldpass = argv[2]; newpass = argv[3]; /* initialize the authentication environment */ asce = ASC_INIT(NULL); if (asce == NULL) { fprintf(stderr, "Error: cannot initialize authentication environment\n"); exit(EXIT_FAILURE); } /* change the user's password */ rc = ASC_CHGPASSWD(asce, user, oldpass, newpass); if (rc == AS_OK) printf("password has been changed\n"); else if (rc == AS_NO) printf("password has not been changed\n"); else printf("RC=%d, %s", rc, ASC_STRERROR(rc));
/* now terminate the authentication environment */ ASC_TERM(asce); return 0; }