Geeks With Blogs

Lance's TextBox

This post is the fourth in a series of postings, containing examples of SharePoint WebParts that anybody can build all by themselves.  To read all posts in this series, or to get started with the RSSBus WebPart, go here.


#4 – List Active Directory Groups and Users

This web part will list each user group and its members, as defined in your Active Directory (or other LDAP server) installation.

Step one is to make sure you have the RSSBus Web Part installed.  See here for instructions.

Step two, make sure you have the Ldap Connector installed.

Step two, add the RSSBus WebPart to your page and paste the following template into its source editor, but do not click “Apply” yet.


<rsb:import lib="RSSBus.LdapOps" />
<input name="showemptygroups" values="false,true" />
</rsb:info> <!-- general ldap connection properties -->
<rsb:set attr="server" value="testman"/>
<rsb:set attr="authdn" value="NS2\\Lance"/>
<rsb:set attr="password" value="*****"/>
<!-- group search settings --> <rsb:set attr="dn" value="dc=NS2"/>
<rsb:set attr="filter" value="objectClass=group"/>
<rsb:set attr="scope" value="WHOLESUBTREE"/>
<!-- group search --> <rsb:call op="ldapSearch" save="groups" />
<rsb:call op="feedGet?feed=[[_feeds.groups | urlencode]]">
<rsb:set attr="showgroup" value="true" />
<rsb:equals attr="showemptygroups" value="false">
<rsb:set attr="showgroup" value="[[ldap:member# | def('0') | equals('0', 'false', 'true')]]" />
<rsb:equals attr="showgroup" value="true">
<a href="javascript:;" onmousedown="toggleDiv('[[ldap:name]]-content');">[[ldap:name]]</a> ([[ldap:member# | def('0')]]) <div id="[[ldap:name]]-content" style="display:none"> <rsb:set attr="dn" value="[[ldap:dn]]"/> <rsb:set attr="scope" value="BASEOBJECT"/>
<rsb:call op="ldapSearch" output="out">
<table width="100%">
<tr style="background-color:LightGrey"><td>samAccountName:</td><td>[[ldap:samaccountname]]</td></tr>
<tr style="background-color:LightGrey"><td>Full Group DN:</td><td>[[ldap:dn]]</td></tr> <tr></tr>
rsb:enum attr="ldap:member">
<tr><td colspan="2">[[_value]]</td></tr>
<hr />
<script> function toggleDiv(div) { var mydiv=document.getElementById(div); if( == 'none') { = 'block'; } else { = 'none'; } } </script>

Step three, we need to modify this template so that it works for your Active Directory server, and not mine!  There are several things you’ll need to change:

1.  On line 8-10, change the values of the server, authentication dn, and authentication password settings to match your AD installation.  See the advanced tip at the bottom of this post to automatically use the logged in user as the authentication dn.
2.  On line 13, you’ll want to modify the value of the dn setting to match your domain.

As always, you can customize the html in the template if you want, or leave it as is.

Step four, click “Apply”, and when the page reloads you’ll be presented with a list of the groups on your Active Directory domain.  Click on a group to expand it into its list of user members.

And now - an Advanced Tip!  Use RSSBus’ special _spuser item in order to get information specific to the currently authenticated SharePoint user.  This comes in handy for things like listing documents that were modified by a specific user, authenticating to an Exchange server, and in this example for authenticating to AD.  You can set the DN to “[[_spuser.LoginName]]”, and prompt the user to enter their own password.

See all posts in this series:  10 DIY SharePoint Web Parts.
Browse RSSBus Connectors.
Basic RSSBus Scripting Cheat Sheet.


Technorati Tags: , ,
Posted on Thursday, July 30, 2009 6:57 AM | Back to top

Comments on this post: 10 DIY SharePoint Web Parts #4

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Lance Robinson | Powered by: