Feedback

C# - Liefert den SecurityIdentifier des UserAccount

Veröffentlicht von am 3/16/2007
(1 Bewertungen)
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;
}
Abgelegt unter SecurityIdentifier, SID, Account.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!