2
ldap_parse_passwordpolicy_control.c - replacement function
4
Copyright (C) 2013 Arthur de Jong
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29
#include "compat/ldap_compat.h"
30
#include "compat/attrs.h"
32
#ifndef PPOLICY_WARNING
33
#define PPOLICY_WARNING 160
36
#define PPOLICY_ERROR 129
38
#ifndef PPOLICY_EXPIRE
39
#define PPOLICY_EXPIRE 128
42
#define PPOLICY_GRACE 129
45
/* based on Openldap and pam_ldap implementations */
47
int ldap_parse_passwordpolicy_control(LDAP UNUSED(*ld), LDAPControl *ctrl,
48
ber_int_t *expirep, ber_int_t *gracep,
49
LDAPPasswordPolicyError UNUSED(*errorp))
55
#ifdef HAVE_BER_GET_ENUM
57
#endif /* HAVE_BER_GET_ENUM */
58
/* get a BerElement from the control */
59
ber = ber_init(&ctrl->ldctl_value);
61
return LDAP_LOCAL_ERROR;
63
for(tag = ber_first_element(ber, &berLen, &last); tag != LBER_DEFAULT; tag = ber_next_element(ber, &berLen, last))
68
ber_skip_tag(ber, &berLen);
69
tag = ber_peek_tag(ber, &berLen);
73
if (ber_get_int(ber, expirep) == LBER_DEFAULT)
76
return LDAP_DECODING_ERROR;
80
if (ber_get_int(ber, gracep) == LBER_DEFAULT)
83
return LDAP_DECODING_ERROR;
88
return LDAP_DECODING_ERROR;
91
#ifdef HAVE_BER_GET_ENUM
93
if (ber_get_enum(ber, &err) == LBER_DEFAULT)
96
return LDAP_DECODING_ERROR;
99
#endif /* HAVE_BER_GET_ENUM */
102
return LDAP_DECODING_ERROR;