本文整理汇总了C#中Principal.GetChangeStatusForProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Principal.GetChangeStatusForProperty方法的具体用法?C# Principal.GetChangeStatusForProperty怎么用?C# Principal.GetChangeStatusForProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Principal
的用法示例。
在下文中一共展示了Principal.GetChangeStatusForProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildFilterSet
private void BuildFilterSet(Principal p, string[] propertySet, QbeFilterDescription qbeFilterDescription)
{
string[] strArrays = propertySet;
for (int i = 0; i < (int)strArrays.Length; i++)
{
string str = strArrays[i];
if (p.GetChangeStatusForProperty(str))
{
object valueForProperty = p.GetValueForProperty(str);
if (valueForProperty as PrincipalValueCollection<string> == null)
{
if (valueForProperty as X509Certificate2Collection == null)
{
object obj = FilterFactory.CreateFilter(str);
if (valueForProperty != null)
{
if (!valueForProperty as bool)
{
if (valueForProperty as string == null)
{
if (valueForProperty as GroupScope == GroupScope.Local)
{
if (valueForProperty as byte[] == null)
{
if (valueForProperty as DateTime? == null)
{
if (valueForProperty as ExtensionCache == null)
{
if (valueForProperty as QbeMatchType != null)
{
((FilterBase)obj).Value = (QbeMatchType)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (ExtensionCache)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (DateTime?)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (byte[])valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (GroupScope)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (string)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = (bool)valueForProperty;
}
}
else
{
((FilterBase)obj).Value = null;
}
qbeFilterDescription.FiltersToApply.Add(obj);
}
else
{
X509Certificate2Collection x509Certificate2Collection = (X509Certificate2Collection)valueForProperty;
X509Certificate2Enumerator enumerator = x509Certificate2Collection.GetEnumerator();
while (enumerator.MoveNext())
{
X509Certificate2 current = enumerator.Current;
object obj1 = FilterFactory.CreateFilter(str);
((FilterBase)obj1).Value = current;
qbeFilterDescription.FiltersToApply.Add(obj1);
}
}
}
else
{
PrincipalValueCollection<string> strs = (PrincipalValueCollection<string>)valueForProperty;
foreach (string inserted in strs.Inserted)
{
object obj2 = FilterFactory.CreateFilter(str);
((FilterBase)obj2).Value = inserted;
qbeFilterDescription.FiltersToApply.Add(obj2);
}
}
}
}
}
示例2: BuildQbeFilterDescription
protected QbeFilterDescription BuildQbeFilterDescription(Principal p)
{
QbeFilterDescription qbeFilterDescription = new QbeFilterDescription();
if (p != null)
{
this.BuildFilterSet(p, StoreCtx.principalProperties, qbeFilterDescription);
}
if (p as AuthenticablePrincipal != null)
{
this.BuildFilterSet(p, StoreCtx.authenticablePrincipalProperties, qbeFilterDescription);
}
if (p as UserPrincipal != null)
{
if (!p.GetChangeStatusForProperty("AuthenticablePrincipal.AccountInfo.AccountExpirationDate") || !p.GetChangeStatusForProperty("AuthenticablePrincipal.AccountInfoExpired"))
{
this.BuildFilterSet(p, StoreCtx.userProperties, qbeFilterDescription);
}
else
{
object[] externalForm = new object[1];
externalForm[0] = PropertyNamesExternal.GetExternalForm("AuthenticablePrincipal.AccountInfo.AccountExpirationDate");
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, StringResources.StoreCtxMultipleFiltersForPropertyUnsupported, externalForm));
}
}
if (p as GroupPrincipal != null)
{
this.BuildFilterSet(p, StoreCtx.groupProperties, qbeFilterDescription);
}
if (p as ComputerPrincipal != null)
{
this.BuildFilterSet(p, StoreCtx.computerProperties, qbeFilterDescription);
}
return qbeFilterDescription;
}
示例3: PushChangesToNative
//
// Native <--> Principal
//
// For modified object, pushes any changes (including IdentityClaim changes)
// into the underlying store-specific object (e.g., DirectoryEntry) and returns the underlying object.
// For unpersisted object, creates a underlying object if one doesn't already exist (in
// Principal.UnderlyingObject), then pushes any changes into the underlying object.
internal override object PushChangesToNative(Principal p)
{
try
{
DirectoryEntry de = (DirectoryEntry)p.UnderlyingObject;
Type principalType = p.GetType();
GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "Entering PushChangesToNative, type={0}", p.GetType());
if (de == null)
{
// Must be a newly-inserted Principal for which PushChangesToNative has not yet
// been called.
// Determine the objectClass of the SAM entry we'll be creating
string objectClass;
if (principalType == typeof(UserPrincipal) || principalType.IsSubclassOf(typeof(UserPrincipal)))
objectClass = "user";
else if (principalType == typeof(GroupPrincipal) || principalType.IsSubclassOf(typeof(GroupPrincipal)))
objectClass = "group";
else
{
throw new InvalidOperationException(
String.Format(CultureInfo.CurrentCulture, StringResources.StoreCtxUnsupportedPrincipalTypeForSave, principalType.ToString()));
}
// Determine the SAM account name for the entry we'll be creating. Use the name from the NT4 IdentityClaim.
string samAccountName = GetSamAccountName(p);
if (samAccountName == null)
{
// They didn't set a NT4 IdentityClaim.
throw new InvalidOperationException(StringResources.NameMustBeSetToPersistPrincipal);
}
lock (_ctxBaseLock)
{
de = _ctxBase.Children.Add(samAccountName, objectClass);
}
GlobalDebug.WriteLineIf(
GlobalDebug.Info, "SAMStoreCtx", "PushChangesToNative: created fresh DE, oc={0}, name={1}, path={2}",
objectClass, samAccountName, de.Path);
p.UnderlyingObject = de;
// set the default user account control bits for authenticable principals
if (principalType.IsSubclassOf(typeof(AuthenticablePrincipal)))
{
InitializeUserAccountControl((AuthenticablePrincipal)p);
}
}
// Determine the mapping table to use, based on the principal type
Hashtable propertyMappingTableByProperty;
if (principalType == typeof(UserPrincipal))
{
propertyMappingTableByProperty = s_userPropertyMappingTableByProperty;
}
else if (principalType == typeof(GroupPrincipal))
{
propertyMappingTableByProperty = s_groupPropertyMappingTableByProperty;
}
else
{
Debug.Assert(principalType == typeof(ComputerPrincipal));
propertyMappingTableByProperty = s_computerPropertyMappingTableByProperty;
}
// propertyMappingTableByProperty has entries for all writable properties,
// including writable properties which we don't support in SAM for some or
// all principal types.
// If we don't support the property, the PropertyMappingTableEntry will map
// it to a converter which will throw an appropriate exception.
foreach (DictionaryEntry dictEntry in propertyMappingTableByProperty)
{
ArrayList propertyEntries = (ArrayList)dictEntry.Value;
foreach (PropertyMappingTableEntry propertyEntry in propertyEntries)
{
if (null != propertyEntry.papiToWinNTConverter)
{
if (p.GetChangeStatusForProperty(propertyEntry.propertyName))
{
GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "PushChangesToNative: pushing {0}", propertyEntry.propertyName);
// The property was set. Write it to the DirectoryEntry.
Debug.Assert(propertyEntry.propertyName == (string)dictEntry.Key);
propertyEntry.papiToWinNTConverter(
p,
//.........这里部分代码省略.........
示例4: GetSamAccountName
private string GetSamAccountName(Principal p)
{
// They didn't set any IdentityClaims, so they certainly didn't set a NT4 IdentityClaim
if (!p.GetChangeStatusForProperty(PropertyNames.PrincipalSamAccountName))
return null;
string Name = p.SamAccountName;
if (Name == null)
return null;
// Split the SAM account name out of the UrnValue
// We accept both "host\user" and "user"
int index = Name.IndexOf('\\');
if (index == Name.Length - 1)
return null;
return (index != -1) ? Name.Substring(index + 1) : // +1 to skip the '/'
Name;
}
示例5: PushChangesToNative
internal override object PushChangesToNative(Principal p)
{
string str;
ArrayList value = null;
object obj;
try
{
DirectoryEntry underlyingObject = (DirectoryEntry)p.UnderlyingObject;
Type type = p.GetType();
if (underlyingObject == null)
{
if (type == typeof(UserPrincipal) || type.IsSubclassOf(typeof(UserPrincipal)))
{
str = "user";
}
else
{
if (type == typeof(GroupPrincipal) || type.IsSubclassOf(typeof(GroupPrincipal)))
{
str = "group";
}
else
{
object[] objArray = new object[1];
objArray[0] = type.ToString();
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, StringResources.StoreCtxUnsupportedPrincipalTypeForSave, objArray));
}
}
string samAccountName = this.GetSamAccountName(p);
if (samAccountName != null)
{
lock (this.ctxBaseLock)
{
underlyingObject = this.ctxBase.Children.Add(samAccountName, str);
}
p.UnderlyingObject = underlyingObject;
if (type.IsSubclassOf(typeof(AuthenticablePrincipal)))
{
this.InitializeUserAccountControl((AuthenticablePrincipal)p);
}
}
else
{
throw new InvalidOperationException(StringResources.NameMustBeSetToPersistPrincipal);
}
}
if (type != typeof(UserPrincipal))
{
if (type != typeof(GroupPrincipal))
{
}
else
{
}
}
else
{
}
foreach (DictionaryEntry dictionaryEntry in value)
{
value = (ArrayList)dictionaryEntry.Value;
IEnumerator enumerator = value.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
SAMStoreCtx.PropertyMappingTableEntry propertyMappingTableEntry = (SAMStoreCtx.PropertyMappingTableEntry)dictionaryEntry;
if (propertyMappingTableEntry.papiToWinNTConverter == null || !p.GetChangeStatusForProperty(propertyMappingTableEntry.propertyName))
{
continue;
}
propertyMappingTableEntry.papiToWinNTConverter(p, propertyMappingTableEntry.propertyName, underlyingObject, propertyMappingTableEntry.suggestedWinNTPropertyName, this.IsLSAM);
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
if (p.GetChangeStatusForProperty("AuthenticablePrincipal.PasswordInfo.Password"))
{
string valueForProperty = (string)p.GetValueForProperty("AuthenticablePrincipal.PasswordInfo.Password");
SDSUtils.SetPassword(underlyingObject, valueForProperty);
}
obj = underlyingObject;
}
catch (COMException cOMException1)
{
COMException cOMException = cOMException1;
throw ExceptionHelper.GetExceptionFromCOMException(cOMException);
}
return obj;
}
示例6: GetSamAccountName
private string GetSamAccountName(Principal p)
{
if (p.GetChangeStatusForProperty("Principal.SamAccountName"))
{
string samAccountName = p.SamAccountName;
if (samAccountName != null)
{
int num = samAccountName.IndexOf('\\');
if (num != samAccountName.Length - 1)
{
if (num != -1)
{
return samAccountName.Substring(num + 1);
}
else
{
return samAccountName;
}
}
else
{
return null;
}
}
else
{
return null;
}
}
else
{
return null;
}
}
示例7: PushChangesToNative
//
// Native <--> Principal
//
// For modified object, pushes any changes (including IdentityClaim changes)
// into the underlying store-specific object (e.g., DirectoryEntry) and returns the underlying object.
// For unpersisted object, creates a underlying object if one doesn't already exist (in
// Principal.UnderlyingObject), then pushes any changes into the underlying object.
internal override object PushChangesToNative(Principal p)
{
GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADStoreCtx", "Entering PushChangesToNative, type={0}", p.GetType());
try
{
DirectoryEntry de = (DirectoryEntry)p.UnderlyingObject;
if (de == null)
{
// Must be a newly-inserted Principal for which PushChangesToNative has not yet
// been called.
// Determine the objectClass of the AD entry we'll be creating
string objectClass;
Type principalType = p.GetType();
// read the rdnPrefix off of the class attribute. This defaults to CN for the internal classes
string rdnPrefix = p.ExtensionHelper.RdnPrefix;
string rdnValue = null;
string baseObjectRdnPrefix = null;
if (principalType == typeof(UserPrincipal))
objectClass = "user";
else if (principalType == typeof(GroupPrincipal))
objectClass = "group";
else if (principalType == typeof(ComputerPrincipal))
objectClass = "computer";
else
{
objectClass = p.ExtensionHelper.StructuralObjectClass;
if (null == objectClass || null == rdnPrefix)
{
throw new InvalidOperationException(StringResources.ExtensionInvalidClassAttributes);
}
// We need to determine if this class is dervived from one of the base classes but has a different RdnPrefix
// For the base objects ( User, Computer and Group ) Their RDNPrefix is a required field along with the RDNPrefix for the
// derived object. This is only done for classes that derive from User, Computer or Group. If a user derives his own class from AuthPrincipal
// they are responsible for setting all required base class properties.
if (principalType.IsSubclassOf(typeof(GroupPrincipal)) ||
principalType.IsSubclassOf(typeof(UserPrincipal)) ||
principalType.IsSubclassOf(typeof(ComputerPrincipal)))
{
DirectoryRdnPrefixAttribute[] MyAttribute =
(DirectoryRdnPrefixAttribute[])Attribute.GetCustomAttributes(principalType.BaseType, typeof(DirectoryRdnPrefixAttribute), false);
if (MyAttribute == null)
throw new InvalidOperationException(StringResources.ExtensionInvalidClassAttributes);
string defaultRdn = null;
// Search for the rdn prefix. This will use either the prefix that has a context type
// that matches the principals context or the first rdnPrefix that has a null context type
for (int i = 0; i < MyAttribute.Length; i++)
{
if ((MyAttribute[i].Context == null && null == defaultRdn) ||
(p.ContextType == MyAttribute[i].Context))
{
defaultRdn = MyAttribute[i].RdnPrefix;
}
}
// If the base objects RDN prefix is not the same as the dervied class then we need to set both
if (defaultRdn != rdnPrefix)
{
baseObjectRdnPrefix = defaultRdn;
}
}
}
// Determine a RDN for the AD entry we'll be creating.
// In order, try:
// (1) The NAme is they set one.
// (2) The SAM account name if they set one
string rdn = null;
if (p.GetChangeStatusForProperty(PropertyNames.PrincipalName))
{
// They set a display name.
string name = (string)p.GetValueForProperty(PropertyNames.PrincipalName);
if ((name != null) && (name.Length > 0))
rdnValue = ADUtils.EscapeDNComponent(name);
}
if (rdnValue == null)
{
if (p.GetChangeStatusForProperty(PropertyNames.PrincipalSamAccountName))
{
// They set a sAMAccountName. If it's an invalid claim, we'll just ignore it here.
//.........这里部分代码省略.........