public Translate ( Type targetType ) : |
||
targetType | Type | |
return |
public override IdentityReference Translate(Type targetType)
{
if (targetType == null)
{
throw new ArgumentNullException(nameof(targetType));
}
Contract.EndContractBlock();
if (targetType == typeof(NTAccount))
{
return this; // assumes that NTAccount objects are immutable
}
else if (targetType == typeof(SecurityIdentifier))
{
IdentityReferenceCollection irSource = new IdentityReferenceCollection(1);
irSource.Add(this);
IdentityReferenceCollection irTarget;
irTarget = NTAccount.Translate(irSource, targetType, true);
return irTarget[0];
}
else
{
throw new ArgumentException(SR.IdentityReference_MustBeIdentityReference, nameof(targetType));
}
}
NTAccount::Translate ( IdentityReferenceCollection sourceAccounts, Type targetType, bool forceSuccess ) : IdentityReferenceCollection |
private void btnOK_Click(object sender, EventArgs e) { bool success = false; try { Sid = new SecurityIdentifier(textBoxSid.Text); success = true; } catch (Exception) { } if (!success) { try { NTAccount acct = new NTAccount(textBoxSid.Text); Sid = (SecurityIdentifier)acct.Translate(typeof(SecurityIdentifier)); success = true; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (success) { DialogResult = DialogResult.OK; Close(); } }