Multiple ldap DataConnectors returning attributes wit the same name
Daniel Fisher
dfisher at vt.edu
Mon Jun 10 17:47:30 EDT 2013
On Mon, Jun 10, 2013 at 3:17 PM, Douglas E. Engert <deengert at anl.gov> wrote:
>
>
> On 6/5/2013 5:14 PM, Cantor, Scott wrote:
> > On 6/5/13 4:02 PM, "Douglas E. Engert" <deengert at anl.gov> wrote:
> >>
> >> I would like to have two LDAP DataConnectors that both need to return a
> >> CN attribute.
> >> How can I have one return CN as the attribute and the other return some
> >> other name so the two attributes don't get mixed up?
> >>
> >> I may be missing something simple, but is there a way to add a prefix
> >> to the name of the attributes listed in one of the <ReturnAttributes>
> >
> > Not that I'm aware (if there is Daniel will know, or you'll find
> something
> > in the vt-ldap docs about it). There definitely is nothing in the IdP
> > itself.
>
> Did not find any info in their docs, and no one from vt-ldap has responded.
>
>
You can write a search result handler to copy the ldap attribute:
{code}
public class CopyCnSearchResultHandler extends CopySearchResultHandler
{
protected Attributes processAttributes(
final SearchCriteria sc,
final SearchResult sr)
throws NamingException
{
final Attributes newAttrs = sr.getAttributes();
if (newAttrs.get("cn") != null) {
final Attribute attr = newAttrs.get("cn");
final Attribute newAttr = new BasicAttribute("copy-cn",
attr.isOrdered());
final NamingEnumeration<?> en = attr.getAll();
while (en.hasMore()) { newAttr.add(en.next()); }
newAttrs.put(newAttr);
}
return newAttrs;
}
}
{code}
Then add your handler as a property in your resolver configuration:
<LDAPProperty
name="edu.vt.middleware.ldap.searchResultHandlers"
value="edu.vt.middleware.ldap.handler.FqdnSearchResultHandler,edu.vt.middleware.ldap.handler.EntryDnSearchResultHandler,edu.vt.middleware.ldap.handler.BinarySearchResultHandler,CopyCnSearchResultHandler"/>
Note that setting this property overrides the existing result handler
configuration, which is why I added them back in addition to the copy cn
handler.
If you are using the mergeResults or lowercasing options, those handlers
must be added as well.
--Daniel Fisher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/users/attachments/20130610/d0dc8831/attachment-0001.html
More information about the users
mailing list