You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by Ca...@ibs-ag.com on 2013/02/02 00:13:57 UTC
Password policy response, ideas?
Hi, I've tried everything I can think of but cannot get the BindResponse cast to the PasswordPolicyResponse object I need.
When I breakpoint the line Control control= .. I can see the data I'm looking for is there. I just can't' get it into a useable object.
I get
java.lang.ClassCastException:
org.apache.directory.api.ldap.codec.BasicControlDecorator cannot be cast to org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator
I want to bind with a password policy control, get the response and retrieve the policy error.
Thanks..
Here is the pseudo code.
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn(dn);
bindRequest.setCredentials(strPassword);
LdapApiService codec = LdapApiServiceFactory.getSingleton();
PasswordPolicyDecorator pwCtrl = new PasswordPolicyDecorator(codec,new PasswordPolicyImpl());
bindRequest.addControl(pwCtrl);
bindResponse = connection.bind(bindRequest);
if (bindResponse.hasControl(PasswordPolicy.OID))
{
Control control = ((Response)bindResponse).getControls().get( PasswordPolicy.OID );
PasswordPolicy pwPolicy = ((PasswordPolicyDecorator)control).getDecorated(); // exception thrown here!
PasswordPolicyResponse pw = pwPolicy.getResponse(); //<- this is where I 'm trying to get.
}
Thanks!
RE: Password policy response, ideas?
Posted by Ca...@ibs-ag.com.
That works! I had this set on the server, in the wrapper.conf.. I didn't have it in our classes. Thanks Kiran!
-----Original Message-----
From: ayyagarikiran@gmail.com [mailto:ayyagarikiran@gmail.com] On Behalf Of Kiran Ayyagari
Sent: Friday, February 01, 2013 10:26 PM
To: users@directory.apache.org
Subject: Re: Password policy response, ideas?
by default the support for ppolicy control is not enabled to enabled it set the system property extra.controls
System.setProperty( "extra.controls",
"org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory"
);
this must be done in a static block
and then run the program
see the apacheds.sh script [1] for a list of default and non-default controls
[1]
http://svn.apache.org/repos/asf/directory/apacheds/trunk/service/apacheds.sh
On Sat, Feb 2, 2013 at 4:43 AM, <Ca...@ibs-ag.com> wrote:
> Hi, I've tried everything I can think of but cannot get the
> BindResponse cast to the PasswordPolicyResponse object I need.
> When I breakpoint the line Control control= .. I can see the data I'm
> looking for is there. I just can't' get it into a useable object.
> I get
> java.lang.ClassCastException:
> org.apache.directory.api.ldap.codec.BasicControlDecorator cannot be
> cast to
> org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPol
> icyDecorator
>
> I want to bind with a password policy control, get the response and
> retrieve the policy error.
> Thanks..
>
> Here is the pseudo code.
>
> BindRequest bindRequest = new BindRequestImpl();
> bindRequest.setDn(dn);
> bindRequest.setCredentials(strPassword);
>
> LdapApiService codec =
> LdapApiServiceFactory.getSingleton();
> PasswordPolicyDecorator pwCtrl = new
> PasswordPolicyDecorator(codec,new PasswordPolicyImpl());
>
> bindRequest.addControl(pwCtrl);
> bindResponse = connection.bind(bindRequest);
>
> if (bindResponse.hasControl(PasswordPolicy.OID))
> {
> Control control =
> ((Response)bindResponse).getControls().get( PasswordPolicy.OID );
> PasswordPolicy pwPolicy =
> ((PasswordPolicyDecorator)control).getDecorated(); // exception thrown here!
>
> PasswordPolicyResponse pw = pwPolicy.getResponse();
> //<- this is where I 'm trying to get.
>
> }
>
> Thanks!
>
>
>
--
Kiran Ayyagari
http://keydap.com
Re: Password policy response, ideas?
Posted by Kiran Ayyagari <ka...@apache.org>.
by default the support for ppolicy control is not enabled to enabled it set
the system property extra.controls
System.setProperty( "extra.controls",
"org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory"
);
this must be done in a static block
and then run the program
see the apacheds.sh script [1] for a list of default and non-default
controls
[1]
http://svn.apache.org/repos/asf/directory/apacheds/trunk/service/apacheds.sh
On Sat, Feb 2, 2013 at 4:43 AM, <Ca...@ibs-ag.com> wrote:
> Hi, I've tried everything I can think of but cannot get the BindResponse
> cast to the PasswordPolicyResponse object I need.
> When I breakpoint the line Control control= .. I can see the data I'm
> looking for is there. I just can't' get it into a useable object.
> I get
> java.lang.ClassCastException:
> org.apache.directory.api.ldap.codec.BasicControlDecorator cannot be cast
> to
> org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator
>
> I want to bind with a password policy control, get the response and
> retrieve the policy error.
> Thanks..
>
> Here is the pseudo code.
>
> BindRequest bindRequest = new BindRequestImpl();
> bindRequest.setDn(dn);
> bindRequest.setCredentials(strPassword);
>
> LdapApiService codec =
> LdapApiServiceFactory.getSingleton();
> PasswordPolicyDecorator pwCtrl = new
> PasswordPolicyDecorator(codec,new PasswordPolicyImpl());
>
> bindRequest.addControl(pwCtrl);
> bindResponse = connection.bind(bindRequest);
>
> if (bindResponse.hasControl(PasswordPolicy.OID))
> {
> Control control =
> ((Response)bindResponse).getControls().get( PasswordPolicy.OID );
> PasswordPolicy pwPolicy =
> ((PasswordPolicyDecorator)control).getDecorated(); // exception thrown here!
>
> PasswordPolicyResponse pw = pwPolicy.getResponse();
> //<- this is where I 'm trying to get.
>
> }
>
> Thanks!
>
>
>
--
Kiran Ayyagari
http://keydap.com