[ 
https://issues.apache.org/jira/browse/DIRSERVER-1448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12802330#action_12802330
 ] 

RAMESH BABU NAKKA commented on DIRSERVER-1448:
----------------------------------------------

Hi, 
We are doing the update of the user by the below code, we dont have an LDIF for 
the users which we update during the running of  testng tests.
Please suggest us if you need any more information


public class UserDaoImpl implements WrappedUserDao {    

static Logger logger = LoggerFactory.getLogger(UserDaoImpl.class);

        @Autowired
        LdapTemplate ldapTemplate;
        @Autowired
        EnvironmentUtil envirnomentutil;
        @Autowired
        LDAPUtil ldaputil;
        

public void update(User info) {
                try{
                        if(info!=null){
                                 DistinguishedName dn = new DistinguishedName();
                                 dn.addAll(new DistinguishedName("cn=users"));
                                 dn.add("uid", "sampleUser112");                
                                 DirContextAdapter  context = 
(DirContextAdapter) ldapTemplate.lookupContext(dn);
                                 context.setUpdateMode(true);
                                 mapToContext(info, context);   
                                 
ldapTemplate.modifyAttributes(dn,context.getModificationItems());
                        }else{
                                //TODO: Throw exception
                                if(logger.isErrorEnabled()){
                                        logger.error("Update user failed, since 
user object is null");
                                }       
                        }
                }catch (Exception e) {
                        // TODO: handle exception                       
                        if(logger.isErrorEnabled()){
                                logger.error("Failed updating user : : " + 
e.getMessage());
                        }
                        e.printStackTrace();
                }
        }




protected void mapToContext (User user, DirContextAdapter context) {
                try{
                        
                        User oldUser = findByUserId(user.getUserId());
                        
                        if(oldUser==null){
                                oldUser = new User();
                        }
                        
                        //TODO: Externalize to property file.
                        context.setAttributeValues(LDAPConstants.OBJECT_CLASS, 
new String[] {LDAPConstants.TOP, LDAPConstants.PORTAL_USER});
                        
                        if(user!=null){
                                
                                
if(ValidationUtil.isNotNullOrBlank(user.getUserId())){
                                        prepareContextFromUserObject(context, 
user.getUserId(), oldUser.getUserId(), 
UserAttributes.USER_ID.getLDAPAttributeName());
                                        prepareContextFromUserObject(context, 
user.getUserId(), oldUser.getUserId(), 
UserAttributes.CN.getLDAPAttributeName());
                                }else{
                                        //@TODO throw exception for mandatory 
attributes                        
                                }
                                
                                
if(ValidationUtil.isNotNullOrBlank(user.getLastName())){
                                        prepareContextFromUserObject(context, 
user.getLastName(), oldUser.getLastName(), 
UserAttributes.USER_LAST_NAME.getLDAPAttributeName());                          
       
                                }else{
                                        //@TODO throw exception for mandatory 
attributes                        
                                }
                                
                                
                                prepareContextFromUserObject(context, 
user.getFirstName(), oldUser.getFirstName(), 
UserAttributes.USER_FIRST_NAME.getLDAPAttributeName());
                                
                                prepareContextFromUserObject(context, 
user.getUserType(), oldUser.getUserType(), 
UserAttributes.USER_TYPE.getLDAPAttributeName());
                                
                                prepareContextFromUserObject(context, 
user.getPassword(), oldUser.getPassword(), 
UserAttributes.USER_PASSWORD.getLDAPAttributeName());
                                
                                .
                                .
                                .
                                .
                                .
                                .
                                .
                                .
                                .
}               
}.

These are the LDAP settings we use for 
local.ldap=APACHEDS
local.ldap.url=ldap://localhost:10389
local.ldap.base=dc=portal,dc=osc,dc=state,dc=ny,dc=us
local.ldap.basedn=uid=admin,ou=system
local.ldap.password=secret
local.ldap.userbase=cn=users
local.ldap.groupbase=cn=groups



> Unable to update User attributes 
> ---------------------------------
>
>                 Key: DIRSERVER-1448
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1448
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 1.5.5
>         Environment: Windows, Java Embedded Apache DS
>            Reporter: RAMESH BABU NAKKA
>            Priority: Blocker
>
> I am using the embedded APACHE DS API 1.5.5. 
> We are starting and stopping the DS through testng tests
> We are able to create partition, add users, find users,      but not able to 
> update users with any attribute (Single valued and Multi valued.)
> Initially we thought we are not able to updated for multi values attributes, 
> but we are UNABLE to update any user attribute.
> We get the below exception.
> java.lang.NullPointerException
>       at 
> org.apache.directory.server.core.collective.CollectiveAttributesSchemaChecker.checkModify(CollectiveAttributesSchemaChecker.java:89)
>       at 
> org.apache.directory.server.core.collective.CollectiveAttributeInterceptor.modify(CollectiveAttributeInterceptor.java:358)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.subtree.SubentryInterceptor.modify(SubentryInterceptor.java:1104)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.schema.SchemaInterceptor.modify(SchemaInterceptor.java:1551)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.operational.OperationalAttributeInterceptor.modify(OperationalAttributeInterceptor.java:209)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.changelog.ChangeLogInterceptor.modify(ChangeLogInterceptor.java:225)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.exception.ExceptionInterceptor.modify(ExceptionInterceptor.java:367)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor.modify(DefaultAuthorizationInterceptor.java:273)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.authz.AciAuthorizationInterceptor.modify(AciAuthorizationInterceptor.java:565)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.referral.ReferralInterceptor.modify(ReferralInterceptor.java:403)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.authn.AuthenticationInterceptor.modify(AuthenticationInterceptor.java:336)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.modify(InterceptorChain.java:1216)
>       at 
> org.apache.directory.server.core.normalization.NormalizationInterceptor.modify(NormalizationInterceptor.java:146)
>       at 
> org.apache.directory.server.core.interceptor.InterceptorChain.modify(InterceptorChain.java:821)
>       at 
> org.apache.directory.server.core.DefaultOperationManager.modify(DefaultOperationManager.java:691)
>       at 
> org.apache.directory.server.core.DefaultCoreSession.modify(DefaultCoreSession.java:829)
>       at 
> org.apache.directory.server.core.DefaultCoreSession.modify(DefaultCoreSession.java:815)
>       at 
> org.apache.directory.server.ldap.handlers.ModifyHandler.handle(ModifyHandler.java:56)
>       at 
> org.apache.directory.server.ldap.handlers.ModifyHandler.handle(ModifyHandler.java:39)
>       at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:176)
>       at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:56)
>       at 
> org.apache.mina.handler.demux.DemuxingIoHandler.messageReceived(DemuxingIoHandler.java:232)
>       at 
> org.apache.directory.server.ldap.LdapProtocolHandler.messageReceived(LdapProtocolHandler.java:194)
>       at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:721)
>       at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:433)
>       at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
>       at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:801)
>       at 
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:71)
>       at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to