Changes the password of a user.
#include <ascauth.h>
int ASC_CHGPASSWD(ASCENV *asce, char *user, char *oldpass, char *newpass);
asce |
The environment item returned from the call to ASC_INIT() or ASC_INIT_EXT(). |
user |
The Enterprise User ID whose password is to be changed. |
oldpass |
The old password for the user. |
newpass |
The new password for the user. |
Returns one of the following integer values defined in ascauth.h:
AS_OK |
Password changed |
AS_NO |
Old password is invalid |
AS_NOUSER |
User inactive or not found in the Census |
AS_REVOKED |
User's password is okay, but the user is disabled |
AS_INTRUDER |
Intruder lockout is enabled for this user |
AS_PASSDUPLICATE |
New password has been used previously |
AS_PASSTOOSHORT |
New password is too short |
AS_BADCLIENT |
Local host not authorized to query the Core Driver |
AS_NOAGENT |
No Core Driver could be contacted |
AS_NOAUTHENV |
No environment has been established |
AS_INVALIDREQ |
Call rejected by the Core Driver as not valid or not supported |
AS_INVALIDARGS |
Invalid arguments supplied to the function |
AS_KEYEXPIRED |
Old key rejected by the Core Driver because the expiration date has passed |
#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; }