Using Password Policy one can achieve
a. Password Expiration
b. Before Expiration User gets warning to change the password
Step1. Enable policy Overlay, It can be done by installing the schema.
1$ ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/ppolicy.ldif
For Verification, whether it is done or not
1$ ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config dn
Step2. We need to write to the directory where are all policies will be filename: policies_1.ldif
dn : ou = Policies , dc = ktree , dc = org
objectClass : top
objectClass : organizationalUnit
ou : Policies
description : policies come here
To apply to the directory :
1$ ldapadd -D cn=admin,dc=ktree,dc=org -W -f policies_1.ldif
Step3. Now, We load the Modules handling the policies.
1filename: policy_module.ldif2dn : cn = module { 0 }, cn = config3changetype : modify4add : olcModuleLoad5olcModuleLoad : ppolicy
1To apply to the directory :2$ ldapadd -Y EXTERNAL -H ldapi:/// -f policy_module.ldif
1For verification, modules loaded?2$ ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=module{0},cn=config
Step4. Now tell directory where to look for the policies.
filename: policy_overlay.ldif
1dn : olcOverlay ={ 0 } ppolicy , olcDatabase ={ 1 } hdb , cn = config2objectClass : olcOverlayConfig3objectClass : olcPPolicyConfig4olcOverlay : { 0 } ppolicy5olcPPolicyDefault : cn = DefaultPPolicy , ou = Policies , dc = ktree , dc = org
1To apply to the directory2$ ldapadd -Y EXTERNAL -H ldapi:/// -f policy_overlay.ldif
1For Verification, Overlays in use2$ ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b olcDatabase={1}hdb,cn=config
Step5. Now we can create default policy objects.
filename: Default_Policies.ldiif
1dn : cn = DefaultPPolicy , ou = Policies , dc = ktree , dc = org2cn : DefaultPPolicy3objectClass : pwdPolicy4objectClass : device5objectClass : top6pwdAttribute : userPassword7pwdMaxAge : 25920008pwdExpireWarning : 21600009pwdInHistory : 310pwdCheckQuality : 111pwdMinLength : 812pwdMaxFailure : 313pwdLockout : TRUE14pwdLockoutDuration : 3015pwdGraceAuthNLimit : 016pwdFailureCountInterval : 017pwdMustChange : TRUE18pwdAllowUserChange : TRUE19pwdSafeModify : FALSE
Note : Here pwdExpireAge, object tells us when to expire. It takes input in seconds. Here it is for 30 days. pwdExpireWarning gives tells us when to issue warning before password expiry i.e 25 days.
1To apply to the directory2$ ldapadd -D cn=admin,dc=ktree,dc=org -W -f Default_Policies.ldif
1For Verification2$ ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=DefaultPPolicy,ou=Policies,dc=ktree,dc=or
Testing
Choose an account from the directory, suppose
1dn: uid=user1,ou=People,dc=ktree,dc=org
A. Now to check expiration date, modify timestamp before a month
1filename: change_timestamp.ldif2dn : uid = user1, ou = People, dc = ktree, dc = org3changetype : modify4replace : pwdChangedTime5pwdChangedTime : 20150110192853Z
Note:Here syntax for pwdChanedTime: (YYYYMMDDHHMMSST)
T stands for time zone (GMT)
- To apply to the directory
1$ ldapmodify -D cn=admin,dc=ktree,dc=org -W -e relax -f change_timestamp.ldif
- For verification check with by login in with uid=user1
1$ ldapwhoami -e ppolicy -x -D uid=user1,ou=People,dc=ktree,dc=org -W
- It will not allow you to login
B. To check for the password warning, put time stamp between (25th day to 30th day). and repeat the same steps, now it will throw a message saying “Password expires in somanyseconds” and allows you to login



