Picking attributes from LDAP

View: New views
2 Messages — Rating Filter:   Alert me  

Picking attributes from LDAP

by Álvaro Manso Gutiérrez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I need to pick the user attributes from LDAP.
I have changed the deployerConfigContext.xml as It is explained in CASUM, so now the class of the attributeRepository is LdapPersonAttributeDao.

Do I need to change something in the code because of this class change (from StubPersonAttributeDao to LdapPersonAttributeDao) ?
Do I need to explicity the services where I need the attributes, or are there any way to use the attributes in any service? because I want to have the attributes available in all the services.

_______________________________________________
cas-dev mailing list
cas-dev@...
http://tp.its.yale.edu/mailman/listinfo/cas-dev

Parent Message unknown Re: Picking attributes from LDAP

by Álvaro Manso Gutiérrez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My problem is that the baseDN of my LDAP is dynamic and not static. This is how I've solved the problem, maybe it is not the best way to solve it, so I accept suggestions.

I created a class that implements CredentialsToPrincipalResolver, as in the class AbstractPersonDirectoryCredentialsToPrincipalResolver I have the attribute attributeRepository, I've defined it as LdadPersonAttributeDao in deployerConfigContext.xml but in the definition of the attribute I'm doing:

private IPersonAttributeDao attributeRepository = new StubPersonAttributeDao();

because if I create the object as LdapPersonAttributeDao I always have a NullPointerException because context source is null (¿?).

As I need to change the baseDN for getting my attributes from LDAP, and this attribute is in application level, I have created a temporary variable in the method resovePrincipal. I assigned the value of baseDN to this variable, then I change the value of baseDN, and in the finally assigment I assigne the value of the variable to the baseDN again.
This is a part of my code:

    public final Principal resolvePrincipal(final Credentials credentials) {
        String base =  null;
      [...]
        try{
      [...]
            if(this.attributeRepository.getClass()==org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao.class){
                base =  ((LdapPersonAttributeDao)this.attributeRepository).getBaseDN();                                            ((LdapPersonAttributeDao)this.attributeRepository).setBaseDN("ou=whatever","+ base);
            } 
            attributes = this.attributeRepository.getUserAttributes(principalId);
           
        }finally{
            if (base != null){
                ((LdapPersonAttributeDao)this.attributeRepository).setBaseDN(base);
            }
        }
        [...]
  
    }


As I said, it is not beautiful but it works. Maybe the solution could be easier, but I didn't find a better one.

Cheers

_______________________________________________
cas-dev mailing list
cas-dev@...
http://tp.its.yale.edu/mailman/listinfo/cas-dev