ASC_CHKPASSWD

Verifies the password of a user.

Syntax

#include <ascauth.h>
int ASC_CHKPASSWD(ASCENV *asce, char *user, char *pass, ASCUSER *ascu);

Parameters

asce

The environment item returned from the call to ASC_INIT() or ASC_INIT_EXT().

user

The Enterprise User ID to be checked.

pass

The password to be checked for the user.

ascu

The ASCUSER structure (defined in ascauth.h) to be filled in by ASC_CHKPASSWD() if the password is valid.

Return Values

Returns one of the following integer values defined in ascauth.h:

AS_OK

Password is okay

AS_NO

User ID/Password combination 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 enabled for this user

AS_BADCLIENT

Local host is 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

If an AS_OK return code is returned, the following fields in the ASCUSER structure contain additional information about the authenticated user:

<ascu>.pass.expire

Number of seconds until the password expires (or -1 if the password does not expire)

<ascu>.pass.interval

Password change interval in seconds (or -1 if the password does not expire)

If an AS_REVOKED code is returned, the following field in the ASCUSER structure contains additional information about the user:

<ascu>.login.disabled

User disabled flag

Example

#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;
}

See Also

ASC_INIT

ASC_INIT_EXT

ASC_TERM

ASC_STRERROR