Liefert den SecurityIdentifier des UserAccount
/// <summary>
/// Liefert den SecurityIdentifier des UserAccount.
/// </summary>
/// <param name="Domain">Name der Windows-Domain</param>
/// <param name="User">Name des UserAccounts</param>
/// <example>
/// System.Security.Principal.SecurityIdentifier SID = GetSIDfromUserName(Environment.UserDomainName, Environment.UserName);
/// string SIDValue = SID.value;
/// </example>
public System.Security.Principal.SecurityIdentifier GetSIDfromUserName(string Domain, string User)
{
System.Security.Principal.NTAccount NTUser = new System.Security.Principal.NTAccount(Domain, User);
System.Security.Principal.SecurityIdentifier SID = (System.Security.Principal.SecurityIdentifier)NTUser.Translate(typeof(System.Security.Principal.SecurityIdentifier));
return SID;
}
Kommentare zum Snippet