Announcement Announcement Module
Collapse
No announcement yet.
German Characher with LDAP search Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • German Characher with LDAP search

    Hi ;

    I have problem with LDAP, when I search on DN that have any germane character like , , that return exception , although that DN is exists.

    I search on DN like 'CN=******,CN=*******,DC=*******t,DC=de'

    The Exception is:
    Code:
    org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001C6, problem 2001 (NO_OBJECT), data 0, best match of:
    	'CN=*******,DC=*******t,DC=de'
    nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001C6, problem 2001 (NO_OBJECT), data 0, best match of:
    	'CN=*******,DC=*******,DC=de' remaining name ''
    Caused by: 
    javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001C6, problem 2001 (NO_OBJECT), data 0, best match of:
    	'CN=*******,DC=*******,DC=de'
    	
    	remaining name ''
    	at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
    	at com.sun.jndi.ldap.LdapCtx.c_getAttributes(Unknown Source)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(Unknown Source)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(Unknown Source)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(Unknown Source)
    	at javax.naming.directory.InitialDirContext.getAttributes(Unknown Source)
    	at javax.naming.directory.InitialDirContext.getAttributes(Unknown Source)
    	at org.springframework.ldap.core.LdapTemplate$12.executeWithContext(LdapTemplate.java:830)
    	at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:775)
    	at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:762)
    	at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:827)
    	at com.asaltech.tool.ldap.CommunityDAO.findLdapAttributes(CommunityDAO.java:87)
    	at com.asaltech.tool.controller.editLDAPSettingsController.onSubmit(editLDAPSettingsController.java:93)
    	at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:156)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    	at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    	at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    	at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	at java.lang.Thread.run(Unknown Source)

    Create ldapTemplate :
    Code:
    public void setupLDAP(LdapSettings settings) {
    
    		logger.info("Setting up the LDAP");
    
    		try{
    			Map<String,String> baseEnvironmentProperties = new HashMap<String, String>();
    			baseEnvironmentProperties.put("java.naming.ldap.attributes.binary", "objectGUID");
    
    			
    			this.settings = settings;
    			contextSource = new LdapContextSource();
    			contextSource.setUrl(settings.getHost() + ":" + settings.getPort());
    			contextSource.setBase(settings.getBaseDN());
    			contextSource.setUserDn(settings.getUserDN());  
    			contextSource.setPassword(settings.getUserPassword());
    			contextSource.setBaseEnvironmentProperties(baseEnvironmentProperties);
    			contextSource.afterPropertiesSet();
    			
    			ldapTemplate = new LdapTemplate();
    			ldapTemplate.setIgnorePartialResultException(true);
    			ldapTemplate.setContextSource(contextSource);
    		}
    		catch(Exception exp){
    			logger.error("setupLDAP", exp);
    			throw new LdapFetchingDataException(exp);
    		}
    	}
    Search Function:

    Code:
    public List findObjectGUID(){
    
    	List lstGoDBs = null;
    
    		try{
    			SearchControls sc = new SearchControls();
    			sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
    			sc.setReturningObjFlag(true);
    			PagedResultsRequestControl control = new PagedResultsRequestControl(100);
    
    			byte[] cookie ;
    			do
    			{
    
    			List temp = ldapTemplate.search("" , "(objectclass=*)", sc ,
    						new ObjectGuidMapper(), control);
    			control = new PagedResultsRequestControl(100, control.getCookie());
    
    				
    			cookie = control.getCookie().getCookie();
    
    			if(lstGoDBs != null ){
    				lstGoDBs.addAll(temp);
    			}else{
    				lstGoDBs = new ArrayList();
    				lstGoDBs.addAll(temp);
    			}
    		}
    	while ((cookie != null) && (cookie.length != 0));
    	}
    	catch(Exception ex){
     		logger.error(Exception );
    	}
    	return lstGoDBs;
    }

    Class Attributes Mapper:
    Code:
    class ObjectGuidMapper implements AttributesMapper{
    
    	public Object mapFromAttributes(Attributes attributes)
    		throws javax.naming.NamingException {
    			
    		ObjectGUID objectGUID = new ObjectGUID();
    
    		if (attributes.get("distinguishedName") !=null){ //distinguishedName
    				objectGUID.setDn(attributes.get("distinguishedName").get().toString());
    		}
    
    		if (null != attributes.get("objectGUID")){
    			byte[] guid = (byte[])attributes.get("objectGUID").get();
    				objectGUID.setGuid(decodeObjectGUID(guid));
    		}
    		return objectGUID;	
    	}
    }
    any on can help me?

  • #2
    Your stack trace refers to the method findLdapAttributes, which is not included in your posted code. Are you certain your code works for "normal" entries (i.e. entries with ascii DNs)?

    Comment


    • #3
      Originally posted by rasky View Post
      Your stack trace refers to the method findLdapAttributes, which is not included in your posted code.
      yes, findLdapAttributes method is same as findObjectGUID , but with different criteria search. and the two method throws same exception.

      findLdapAttributes method return List of DN attributes name, and findObjectGUID return List of DN with ObjectGuid.

      findLdapAttributes method:
      Code:
      	public List findLdapAttributes(){
      
      		logger.info("Reading LDAP attributes...");
      
      		List attList = new ArrayList();
      
      		try{
      			attList = (List)ldapTemplate.lookup("", new AttMapper());
      		}
      		catch(Exception exp){
      			logger.error("findLdapAttributes", exp);
      			throw new LdapFetchingDataException(exp);
      		}
      		return attList;
      	}
      AttMapper:
      Code:
      	class AttMapper implements AttributesMapper{
      		public Object mapFromAttributes(Attributes attributes)
      		throws javax.naming.NamingException {
      
      			NamingEnumeration ne = attributes.getIDs();
      			
      			List attList = new ArrayList();
      			String attID = "";
      
      			while(ne.hasMore()){
      				attID = ne.next().toString();
      				
      				attList.add(attID);
      			}
      
      			return attList;
      		}
      	}
      Originally posted by rasky View Post
      Are you certain your code works for "normal" entries (i.e. entries with ascii DNs)?
      yes, it work without and error, just when try to search on DN have German character it not work.

      Comment

      Working...
      X