rwinch / spring-security-jira-to-gh

0 stars 0 forks source link

LDAP-188: Active Directory -- DirContextAdapter.addAttribute, removeAttribute does not work correctly #174

Closed rwinch closed 13 years ago

rwinch commented 14 years ago

Migrated from LDAP-188

I'm using spring-ldap against an Active Directory based LDAP server. I'd like to manage user-group memberships by adding and removing users to groups.

When deleting a membership I use the following code on the looked up group context instance:

context.removeAttributeValue("member", member); this.ldapTemplate.modifyAttributes(context);

Where member is a String that comes from DistinguishedName.toString(), the problem is when instantiating DistinguishedNames with the constructor that takes one String as argument, the attribute names of LdapRdns become lowercase (e.g.: "OU=Sample,OU=Foo" becomes "ou=sample,ou=foo") while parsing. AD has the habit of converting all lowercase key values to uppercase, and thus when trying to call removeAttributeValue with the dn provided, the actual value is not found and therefore no deletion occurs. The same issue occurs when using addAttributeValue.

I don't know if it is strictly a spring-ldap issue, but it would be good to have some kind of solution. Maybe somehow to be able to preserve the case of the DistinguishedName components would be sufficient.

Thanks is advance, M.

rwinch commented 14 years ago

Mark VEREBELYI said:

Oh, I've mistyped the example, here is the correct one: "OU=Sample,OU=Foo" becomes "ou=Sample,ou=Foo". The case of actual values are preserved.

rwinch commented 13 years ago

Ulrik Sandberg said:

Unless I get a patch pretty quickly, I have to defer this.

rwinch commented 13 years ago

Ulrik Sandberg said:

I'm taking a stab it anyway. Attaching the diff, should anyone has anything to say about it.

rwinch commented 13 years ago

Ulrik Sandberg said:

Patch that adds capability to disable lowercasing of keys in DistinguishedName via a System property.

rwinch commented 13 years ago

Ulrik Sandberg said:

I decided to implement a full choice of lower, upper or none. Not sure whether this affects performance, though.

String org.springframework.ldap.core.DistinguishedName.KEY_CASE_FOLD_PROPERTY = "org.springframework.ldap.core.keyCaseFold"

System property that will be inspected to determine whether creating a DistinguishedName will convert the keys to lowercase, convert the keys to uppercase, or leave the keys as they were in the original String, ie none. Default is to convert the keys to lowercase.

Valid values are:

Since 1.3.1

See Also: