Chapter 36. Functions for Handling Passwords

This chapter contains reference information on routines for handling passwords. The routines are listed in Chapter 36, Functions for Handling Passwords.

Table 36.1. Password Handling Routines

Function Description
slapi_pw_find_sv() Determines whether a specified password matches one of the encrypted values of an attribute.
slapi_is_encoded() Checks whether a value is encoded with any known algorithm.
slapi_encode() Encodes a value with the specified algorithm.
slapi_add_pwd_control() Sends back a password expired notification or password expiration warning.
slapi_pwpolicy_make_response_control() Sends back information on the server password policy.

36.1. slapi_pw_find_sv()

Description

This function replaces the deprecated slapi_pw_find() function from previous Directory Server releases.

When the Directory Server stores the password for an entry in the userpassword attribute, it encodes the password using different schemes. Supported schemes are SSHA (default), SHA, CRYPT, and CLEAR.
Use this function to determine if a given password is one of the values of the userpassword attribute. This function determines which password scheme was used to store the password and uses the appropriate comparison function to compare a given value against the encoded values of the userpassword attribute.
Syntax

#include "slapi-plugin.h"
int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );

Parameters

This function takes the following parameters:

vals
Pointer to the array of Slapi_Value structure pointers, containing the values of an attribute that stores passwords (for example, the userpassword attribute).
v
Pointer to the Slapi_Value structure containing the password that you wish to check; for example, you can get this value from the SLAPI_BIND_CREDENTIALS parameter in the parameter block and create the Slapi_Value using slapi_value_init_berval().
Returns

This function returns one of the following values:

  • 0 if the password specified by v was found in vals.
  • A non-zero value if the password v was not found in vals.