Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do it by using <code>UserPrincipal.GetGroups();</code></p> <p>For a complete code here it is</p> <pre><code>/// &lt;summary&gt; /// Gets a list of the users group memberships /// &lt;/summary&gt; /// &lt;param name="sUserName"&gt;The user you want to get the group memberships&lt;/param&gt; /// &lt;returns&gt;Returns an arraylist of group memberships&lt;/returns&gt; public ArrayList GetUserGroups(string sUserName) { ArrayList myItems = new ArrayList(); UserPrincipal oUserPrincipal = GetUser(sUserName); PrincipalSearchResult&lt;Principal&gt; oPrincipalSearchResult = oUserPrincipal.GetGroups(); foreach (Principal oResult in oPrincipalSearchResult) { myItems.Add(oResult.Name); } return myItems; } /// &lt;summary&gt; /// Gets a certain user on Active Directory /// &lt;/summary&gt; /// &lt;param name="sUserName"&gt;The username to get&lt;/param&gt; /// &lt;returns&gt;Returns the UserPrincipal Object&lt;/returns&gt; public UserPrincipal GetUser(string sUserName) { PrincipalContext oPrincipalContext = GetPrincipalContext(); UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName); return oUserPrincipal; } /// &lt;summary&gt; /// Gets the base principal context /// &lt;/summary&gt; /// &lt;returns&gt;Retruns the PrincipalContext object&lt;/returns&gt; public PrincipalContext GetPrincipalContext() { PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sDefaultOU, ContextOptions.SimpleBind, sServiceUser, sServicePassword); return oPrincipalContext; } </code></pre> <p>or for a full AD reference go <a href="http://anyrest.wordpress.com/2010/06/28/active-directory-c/" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload