Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could try the following code:</p> <pre><code>public bool Check_If_Member_Of_AD_Group(string username, string grouptoCheck, string domain, string ADlogin, string ADpassword) {         try {                 string EntryString = null;         EntryString = "LDAP://" + domain;                 DirectoryEntry myDE = default(DirectoryEntry);                 grouptoCheck = grouptoCheck.ToLower();                         myDE = new DirectoryEntry(EntryString, ADlogin, ADpassword);                 DirectorySearcher myDirectorySearcher = new DirectorySearcher(myDE);                 myDirectorySearcher.Filter = "sAMAccountName=" + username;                 myDirectorySearcher.PropertiesToLoad.Add("MemberOf");                 SearchResult myresult = myDirectorySearcher.FindOne();                 int NumberOfGroups = 0;                 NumberOfGroups = myresult.Properties["memberOf"].Count - 1;                 string tempString = null;                 while ((NumberOfGroups &gt;= 0)) {                         tempString = myresult.Properties["MemberOf"].Item[NumberOfGroups];             tempString = tempString.Substring(0, tempString.IndexOf(",", 0));                         tempString = tempString.Replace("CN=", "");                         tempString = tempString.ToLower();             tempString = tempString.Trim();                         if ((grouptoCheck == tempString)) {                                                     return true;             }                                         NumberOfGroups = NumberOfGroups - 1;         }                             return false;     }     catch (Exception ex) {                 System.Diagnostics.Debugger.Break();     }     //HttpContext.Current.Response.Write("Error: &lt;br&gt;&lt;br&gt;" &amp; ex.ToString) } </code></pre>
    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. This table or related slice is empty.
    1. 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