Spring ldap 1.3
step A. createa user in AD like this:
Attributes personAttributes = new BasicAttributes();
personAttributes.put( "objectclass", "person" );
personAttributes.put( "objectclass", "user" );
personAttributes.put( "givenName", luzer.getFirstName() );
personAttributes.put( "userPrincipalName", luzer.getEmailAddress() );
personAttributes.put( "sn", luzer.getLastName());
personAttributes.put( "description", "Created via WFM 5.0 Flex app" );
personAttributes.put( "sAMAccountName", luzer.getFirstName().toUpperCase()+ "." + luzer.getLastName().toUpperCase() );
personAttributes.put( "userAccountControl", "512" ); /// 512 = normal luser
personAttributes.put( "pwdLastSet", "0" ); /// force user to change password on next login......
// PASSWORD stuff.....
personAttributes.put("unicodepwd", encodePassword( luzer.getPassword() ) );
// Set up user distinguished name and clreate it.
DistinguishedName newUserDN = userToDistinguishedName( luzer );
ldapTemplate.bind(newUserDN, null, personAttributes);
All goes well....
User tries to authenticate first time we get back ".... AcceptSecurityContext error, data 773 ....." which means:
// 52e - invalid credentials
// 530 - not permitted to logon at this time
// 532 - password expired
// 533 - account disabled
// 701 - account expired
// 773 - user must reset password
So user is forced to change password. and we do i like this:
ModificationItem repitem = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("unicodepwd", encodePassword( luzer.getPassword() )) );
DistinguishedName userDN = userToDistinguishedName( luzer );
ldapTemplate.modifyAttributes( userDN, new ModificationItem[] { repitem } );
all goes well.....
but now user can not log in anymore......
org.springframework.security.AuthenticationService Exception: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001BD, problem 2001 (NO_OBJECT), data 0, best match of:
'OU=TRX DEV,OU=WFM LDAP,OU=External Clients,DC=trxfs,DC=trx,DC=com'
so what the heck is going on?
ldap base is pointing to
OU=TRX DEV,OU=WFM LDAP,OU=External Clients,DC=trxfs,DC=trx,DC=com
so we create and modify users right at the "root"....
I have spent all day on this and all permutations produce same results.
reseting password with remove+add attribute produces same results....


Reply With Quote