active directory - Grails spring-security-ldap plugin change user password for AD -


i have grails application (2.5.0) using spring security , authenticating spring-security-ldap plugin (2.0-rc2) against windows ad domain.

this works authenticate have requirement allow user change password (in fact require it!).

despite searching through documentation, reading code , searching google can find references ldapuserdetailsmanager.changepassword cannot find single example of how use this.

i find in plugin

public class grailsldapuserdetailsmanager extends ldapuserdetailsmanager      implements grailsuserdetailsservice {.... 

but not have changepassword , not understand how call if did.

i have looked through stackoverflow questions such as

how change password using spring ldap , spring security

but answers appear written in other language , talk things not have xml files.

can tell me, preferably understandable example how can implement change password feature in grails against ldap ad source in conjunction grails spring-security-ldap plugin? authentication without ability manage changing passwords wrong!

you can make use of ldapuserdetailsmanager injecting controller e.g.

gsp:

<!doctype html> <html>     <head>         <meta name="layout" content="main">         <title><g:message code="menu.item.change.password" /></title>     </head>     <body>         <div class="maincontentdiv" role="main">          <div class="alert alert-info alert-dismissible" role="alert">           <button type="button" class="close" data-dismiss="alert" aria-label="close"><span aria-hidden="true">&times;</span></button>           flash.changepasswordmessage         </div>              <h3><g:message code="menu.item.change.password" /></h3>              <g:form class="form-horizontal">                  <div class="form-group">                     <label class="col-md-4 control-label" for="currentpassword">current password</label>                     <div class="col-md-4">                         <g:field type="password" name="currentpassword" class="form-control" required="true" />                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label" for="newpassword">new password</label>                     <div class="col-md-4">                         <g:field type="password" name="newpassword" class="form-control" pattern=".{6,15}" required title="password must minimum of 6 , maximum of 10 characters" />                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label" for="confirmnewpassword">confirm new password</label>                     <div class="col-md-4">                         <g:field type="password" name="confirmnewpassword" class="form-control" pattern=".{6,15}" required title="password must minimum of 6 , maximum of 10 characters" />                     </div>                 </div>                  <g:render template="/templates/generic_submit_button" model="[btnname: 'changepassword', btntxt: 'change password']" />              </g:form>          </div>     </body> </html> 

controller:

class changepasswordcontroller {      def ldapuserdetailsmanager      def index() {         if ( params.changepassword ) {             try {                 if ( params.newpassword.equals( params.confirmnewpassword ) ) {                     ldapuserdetailsmanager.changepassword( params.currentpassword, params.newpassword )                 }                 else {                      throw new invalidparameterexception( 'please ensure new password , confirm new password fields match' )                 }             }             catch( ) {                 flash.changepasswordmessage= all.message             }         }     } } 

Comments