• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get a NDS parameter  RSS feed

 
Joey Alencar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created a class that validate an user in NDS, but I need to get the value of one NDS parameter (called "Company") of the respective user. How can I do this? Please, I really need some help here.
Thanks.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this isn't for a homework assignment. Here's some code that might help you:

"myCtx" is an instance of "DirContext".
"attrName" and "attrValue" are attribute name and value you want to search by. For example, it could be "cn" and "jbrown". The attribute value can contain wild cards, etc., just standard LDAP stuff.
"searchScope" is one of teh valid "SearchControls.XXXX" values (ONELEVEL_SCOPE, OBJECT_SCOPE, SUBTREE_SCOPE, ...). Again pretty standard LDAP stuff.
In the example here it will retrieve all of the attributes from the matching object and save the key/value pairs in a "TreeMap". It only handles String (text) attribute values nicely, and it doesn't have allowance for multi-value attributes. I'm sure you can add those if you need.
It is fairly easy to modify this to handle multiple matches: this code only handles a single match, which is sufficient in many cases.
Hope this helps ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!