Convertir un SID en string
Bonjour,
J'ai une liste de SID (Security IDentifier). Et je souhaite récupérer le sAMAccountName.
J'ai déjà fait un bout de fonction me permettant de retrouver la propriété mais rien à faire j'ai une erreur 0x80005000
Citation:
« l'attribut de service d'annuaire spécifié ou la valeur n'existe pas ».
Voilà ma fonction qui est censé récupéré le sAMAccountName à partir du SID :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
private string ParseSID(string identity)
{
System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(identity);
System.DirectoryServices.DirectoryEntry destDN = new System.DirectoryServices.DirectoryEntry("LDAP://***-***.net/DC=***-***,DC=net/<SID=" + sid.ToString() + ">", "***", "***");
try
{
return (string)destDN.Properties["sAMAccountName"].Value;
}
catch (Exception e)
{
MessageBox.Show("Impossible de résoudre le SID : " + identity + ", nb de propriétés : " + destDN.Properties.Count);
}
return sid.ToString();
} |
Comment vérifier que je me connecte bien au LDAP ?
Pourquoi cette fonction ne me retourne rien ?
Quelqu'un peut m'éclairer ?
Merci