Monday, May 18, 2009

Search users in LDAP

Here you can search users in LDAP by using the below code.

Note: DemoLDAP is the name of the resource which is configured in your IDM.

<Activity id='2' name='search LDAP'>
<Action id='0' name='search LDAP'>
<expression>
<block name='search LDAP..' trace='true'>
<set name='searchResults'>
<invoke name='getResourceObjects' class='com.waveset.ui.FormUtil'>
--returns list of users whose objectClass is Top in LDAP
<invoke name='getLighthouseContext'>
<ref>WF_CONTEXT</ref>
</invoke>
<s>User</s> --- Searching Users
<s>DemoLDAP</s>  -------- Name of LDAP resource which is configured in IDM
<map>
<s>searchContext</s> ---Name of container wherein you want to  perform  search
<s>ou=People,DC=test,DC=edu</s>
<s>searchScope</s>
<s>subTree</s>
<s>searchAttrsToGet</s> --- name of attribute which you want to search (it's value must be a list)
<list>
<s>uid</s>
</list>
<s>searchFilter</s>  ----- attributes on which you want to perfomr your search   
<s>objectClass=Top</s>
</map>
</invoke>
</set>
<dolist name='users'>
<ref>searchResults</ref> ----List of users being searched in above method
<get>
<ref>users</ref>
<s>uid</s>  ---- attribute that you wanted to fetch
</get>
</dolist>
</block>
</expression>
</Action>



searchFilter value could be changed as per your search criteria e.g givenName='John' or city='New York'.