1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
string userName = textBox3.Text;
DirectoryInfo dInfo = new DirectoryInfo(_path);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
string ldapReq = @"(&(objectCategory=user)(samAccountName=" + userName + "))";
string ldapRoot = "LDAP://domain.net/DC=DOMAIN,DC=NET";
DirectoryEntry sroot = new DirectoryEntry(ldapRoot, "toto", "toto");
DirectorySearcher searcher = new DirectorySearcher(sroot, ldapReq, new string[] { "member" }, SearchScope.Subtree);
SearchResult sr = searcher.FindOne();
foreach (string cnMember in sr.GetDirectoryEntry().Properties["sAMAccountName"])
{
MessageBox.Show("L'utilisateur " + userName + " a bien été identifié dans la base LDAP");
// Lui affecter les droits
} |
Partager