Announcement Announcement Module
Collapse
No announcement yet.
unicodePasswd fail to add... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • unicodePasswd fail to add...

    hi

    i am having issue to add new user in AD(windows 2008 AD) with setting password

    my code is below
    Code:
    public void insertContact(ContactDTO contactDTO) {
    try{
    
    	Attributes personAttributes = new BasicAttributes();
    	BasicAttribute personBasicAttribute = new BasicAttribute("objectclass");
    	personBasicAttribute.add("person");
    	personBasicAttribute.add("user");
    	personAttributes.put(personBasicAttribute);
    			
    		personAttributes.put("givenName", contactDTO.getCommonName());
    		personAttributes.put("cn", contactDTO.getCommonName());
    		personAttributes.put("sn", contactDTO.getLastName());
    		personAttributes.put("description", contactDTO.getDescription());
    	
    	personAttributes.put("unicodepwd", this.createUnicodePassword(contactDTO.getPassword()) );
    		
    		personAttributes.put("userPrincipalName", contactDTO.getUserLoginName());
    		personAttributes.put("sAMAccountName", contactDTO.getsAMAccountName());
    		personAttributes.put("displayname", contactDTO.getDisplayname());
    //		personAttributes.put( "pwdLastSet", "0" );
    //		personAttributes.put( "LockOutTime", "0" );
    		
    		personAttributes.put("userAccountControl", "544");
    
    		BasicAttribute roomAttribute = new BasicAttribute("roomNumber");
    		for(String r : contactDTO.getRoomNumber())
    		{
    		  roomAttribute.add(r);
    		}
    		
    		personAttributes.put(roomAttribute);
    				
    		DistinguishedName newContactDN = new DistinguishedName();
    		newContactDN.add("cn", contactDTO.getCommonName());
    		
    		ldapTemplate.bind(newContactDN, null, personAttributes);
    }
    
    
     public  byte[] createUnicodePassword(String password) {
    		 return toUnicodeBytes(doubleQuoteString(password));
    		 }
    
    		 private  byte[] toUnicodeBytes(String str) {
    		 byte[] unicodeBytes = null;
    		 try {
    		 byte[] unicodeBytesWithQuotes = str.getBytes("Unicode");
    		 unicodeBytes = new byte[unicodeBytesWithQuotes.length - 2];
    		 System.arraycopy(
    		 unicodeBytesWithQuotes,
    		 2,
    		 unicodeBytes,
    		 0,
    		 unicodeBytesWithQuotes.length - 2);
    		 } catch (UnsupportedEncodingException e) {
    		 // This should never happen.
    		 e.printStackTrace();
    		 }
    		 return unicodeBytes;
    		 }
    
    		 
    		 private  String doubleQuoteString(String str) {
    		 StringBuffer sb = new StringBuffer();
    		 sb.append("\"");
    		 sb.append(str);
    		 sb.append("\"");
    		 return sb.toString();
    		 }
    but it given me error

    Code:
    org.springframework.ldap.UncategorizedLdapException: Operation failed; nested exception is javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0
    i unable to set the unicodePassword value kindly some One tell me whats going wrong with my code

    i read some where to set unicodePasswd in Ad we need SSL connection with AD can some One show me how i can do that if it required

    please help me out.
    Last edited by Noman sadiq; Dec 7th, 2010, 04:39 AM.

  • #2
    still waiting for reply..

    nobody give me any response please kindly guide me how i can save user with password..
    i read some other info to store user with password in AD
    To set or modify the password of an ADAM user" you should get some information on this.
    Your choices here are:
    0) Perform over SSL connection
    1) Use ldap_opt_encrypt to secure the connection
    2) Disable this security requirement (via the 12th bit of dsHeuristics)


    can any body try this, i not find any solution with last two option to modify and bypass the SSL request for adding unicodepassword
    ..
    if these are not and i have to only use SSL then i follow the link to install the certificate on windows2008 AD server how to create certificate..
    in this document i see Once you have generated a CSR you can use it to order the certificate from a certificate authority.
    my question is that i am totally in Test environment why i order for the certificate this make no sense to purchase certificate to make SSL with your AD server just for the test...

    i again request to any senior member from Spring-ldap community to Guide me to resolve this issue..
    Last edited by Noman sadiq; Dec 7th, 2010, 01:49 AM.

    Comment


    • #3
      Noman,
      Have you looked at this post: http://forum.springsource.org/showthread.php?t=33493

      Give it a try and let me see if I can dig up some more information

      Comment


      • #4
        Here is a link that might help:
        http://forums.oracle.com/forums/thre...5445&tstart=30

        "my question is that i am totally in Test environment why i order for the certificate this make no sense to purchase certificate to make SSL with your AD server just for the test..."
        If you take the SSL path, I am not sure if you have to purchase a certificate. Can't you simple generate a self signed certificate and use it?

        Comment


        • #5
          first of all realy thanks to reply on this thread..
          i know the spring side how i use the SSL in my code,

          but my problem is that i am using new installed AD on server, i am finding difficulty to generate the certificate i have no idea
          1:from where i get these certificate from AD server (windows 2008)
          2:and that how to self signed these cert to use in code

          i have lack of information regarding to these which make me stuck from many dayes..i have no network support so that i am totally confusing on this setup
          kindly give me some little bit guide to generate the certificate and signed them it make my life easy

          the sun forum link which you share with me showing the code but the process of installing the certificates and signed them is missing (not open the ref documents on sun forum may be link are removed now)


          i hope you would come back and reply on this post to complete.
          waiting for your response thanks
          (there is mid night here i will come back in morning )

          Comment


          • #6
            Noman this could be the wrong forum for help in AD certificate. May be some one in the Spring Security fourm might have experience with setting up the certificate.

            Sorry for not being able to help you on this.

            Comment


            • #7
              hmm ok i will be take a look on spring-security may be find something..
              well thanks for replying at least i was sleep well at night will be touch if got problem

              Comment

              Working...
              X