本文整理汇总了C#中System.Security.Principal.SecurityIdentifier.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityIdentifier.Equals方法的具体用法?C# SecurityIdentifier.Equals怎么用?C# SecurityIdentifier.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Principal.SecurityIdentifier
的用法示例。
在下文中一共展示了SecurityIdentifier.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckSidEquivalence
Claim CheckSidEquivalence(SecurityIdentifier identitySid, ClaimSet claimSet)
{
foreach (Claim claim in claimSet)
{
SecurityIdentifier sid = GetSecurityIdentifier(claim);
if (sid != null)
{
if (identitySid.Equals(sid))
{
return claim;
}
}
}
return null;
}
示例2: CheckSidEquivalence
private Claim CheckSidEquivalence(SecurityIdentifier identitySid, ClaimSet claimSet)
{
foreach (Claim claim in claimSet)
{
SecurityIdentifier securityIdentifier = this.GetSecurityIdentifier(claim);
if ((securityIdentifier != null) && identitySid.Equals(securityIdentifier))
{
return claim;
}
}
return null;
}
示例3: EqualsNull
public void EqualsNull ()
{
SecurityIdentifier sid = new SecurityIdentifier (WellKnownSidType.BuiltinUsersSid, null);
Assert.IsFalse (sid.Equals ((object)null));
Assert.IsFalse (sid.Equals ((SecurityIdentifier)null));
}
示例4: RemoveCertificatePrivateKeyAccess
void RemoveCertificatePrivateKeyAccess(X509Certificate2 cert)
{
if (cert != null && cert.HasPrivateKey)
{
try
{
AsymmetricAlgorithm key = cert.PrivateKey;
// Only RSA provider is supported here
if (key is RSACryptoServiceProvider)
{
RSACryptoServiceProvider prov = key as RSACryptoServiceProvider;
CspKeyContainerInfo info = prov.CspKeyContainerInfo;
CryptoKeySecurity keySec = info.CryptoKeySecurity;
SecurityIdentifier ns = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null);
AuthorizationRuleCollection rules = keySec.GetAccessRules(true, false, typeof(SecurityIdentifier));
foreach (AuthorizationRule rule in rules)
{
CryptoKeyAccessRule keyAccessRule = (CryptoKeyAccessRule)rule;
if (keyAccessRule.AccessControlType == AccessControlType.Allow &&
(int)(keyAccessRule.CryptoKeyRights & CryptoKeyRights.GenericRead) != 0)
{
SecurityIdentifier sid = keyAccessRule.IdentityReference as SecurityIdentifier;
if (ns.Equals(sid))
{
CryptoKeyAccessRule nsReadRule = new CryptoKeyAccessRule(ns,
CryptoKeyRights.GenericRead,
AccessControlType.Allow);
keySec.RemoveAccessRule(nsReadRule);
CommitCryptoKeySecurity(info, keySec);
break;
}
}
}
}
}
#pragma warning suppress 56500
catch (Exception e)
{
// CommitCryptoKeySecurity can actually throw any exception,
// so the safest way here is to catch a generic exception while throw on critical ones
if (Utilities.IsCriticalException(e))
{
throw;
}
throw new WsatAdminException(WsatAdminErrorCode.CANNOT_UPDATE_PRIVATE_KEY_PERM,
SR.GetString(SR.ErrorUpdateCertPrivateKeyPerm), e);
}
}
}