internal virtual IEnumerable <T> GetExtendedObjectFromDirectoryObject(ADEntity directoryObject, string xmlAttributeName, string xmlAttributeObjectTypeName) { List <T> ts = new List <T>(); foreach (ADEntity aDEntityFromXmlAttribute in this.GetADEntityFromXmlAttribute(directoryObject, xmlAttributeName, xmlAttributeObjectTypeName)) { ts.Add(this.Construct(aDEntityFromXmlAttribute)); } return(this.ApplyClientSideFilter(ts)); }
internal static bool IsDeleted(ADEntity directoryObj) { if (directoryObj["isDeleted"].Value == null) { return(false); } else { return((bool)directoryObj["isDeleted"].Value); } }
internal static void MergeADObjectProperties(ADEntity parentObj, ADEntity childObj) { parentObj.TrackChanges = false; foreach (string propertyName in childObj.PropertyNames) { if (parentObj.Contains(propertyName)) { continue; } parentObj.Add(propertyName, childObj[propertyName].Value); } parentObj.TrackChanges = true; }
internal static bool IsNamingContext(ADEntity directoryObj) { ADPropertyValueCollection item = directoryObj["instanceType"]; int ret = directoryObj["instanceType"].Value is int?(int)directoryObj["instanceType"].Value : 1; if (directoryObj["instanceType"].Value == null || ret == 0) { return(false); } else { return(Utils.HasFlagsSet((int)item.Value, 1)); } }
internal override T Construct(ADEntity directoryObj, AttributeSetRequest requestedAttributes) { T t = base.Construct(directoryObj, requestedAttributes); string[] internalLdapAttributes = DirectoryAttrConstants.InternalLdapAttributes; for (int i = 0; i < (int)internalLdapAttributes.Length; i++) { string str = internalLdapAttributes[i]; if (!t.InternalProperties.Contains(str) && directoryObj.Contains(str) && directoryObj[str] != null) { t.InternalProperties.SetValue(str, directoryObj[str]); } } return(t); }
private static bool VerifyResourcePropertyValueType(ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo, out ADObject resourcePropertyValueTypeObj, StringBuilder errorBuffer) { bool flag = false; resourcePropertyValueTypeObj = null; if (directoryObj.Contains("msDS-ValueTypeReference")) { string value = directoryObj["msDS-ValueTypeReference"].Value as string; ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>(); aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADResourcePropertyValueType aDResourcePropertyValueType = new ADResourcePropertyValueType(); aDResourcePropertyValueType.Identity = value; string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500); resourcePropertyValueTypeObj = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromIdentity(aDResourcePropertyValueType, str); } else { flag = true; errorBuffer.AppendLine(StringResources.RCTNoResourcePropertyValueTypeError); } return(!flag); }
private static bool EveryoneDeniedDeleteChild(ADEntity directoryObj) { bool flag; ActiveDirectorySecurity value = (ActiveDirectorySecurity)directoryObj["nTSecurityDescriptor"].Value; ActiveDirectoryAccessRule deleteChildAccessRule = ProtectedFromDeletionUtil.ACEConstants.DeleteChildAccessRule; IEnumerator enumerator = value.GetAccessRules(true, true, typeof(SecurityIdentifier)).GetEnumerator(); try { while (enumerator.MoveNext()) { ActiveDirectoryAccessRule current = (ActiveDirectoryAccessRule)enumerator.Current; if (current.AccessControlType != AccessControlType.Allow || !Utils.HasFlagsSet((int)current.ActiveDirectoryRights, 2)) { if (current.InheritanceFlags != deleteChildAccessRule.InheritanceFlags || !(current.IdentityReference == deleteChildAccessRule.IdentityReference) || current.AccessControlType != deleteChildAccessRule.AccessControlType || !Utils.HasFlagsSet((int)current.ActiveDirectoryRights, (int)deleteChildAccessRule.ActiveDirectoryRights)) { continue; } flag = true; return(flag); } else { flag = false; return(flag); } } return(false); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(flag); }
protected override void Validate(object arguments, EngineIntrinsics engineIntrinsics) { if (arguments == null || arguments == AutomationNull.Value) { throw new ValidationMetadataException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidNullValue, new object[0])); } else { ADEntity aDEntity = arguments as ADEntity; if (aDEntity != null) { if (!aDEntity.IsSearchResult) { if (aDEntity.Identity == null || aDEntity.Identity == AutomationNull.Value || aDEntity.Identity as string == string.Empty) { throw new ValidationMetadataException(string.Format(CultureInfo.CurrentCulture, StringResources.NullOrEmptyIdentityPropertyArgument, new object[0])); } else { ADEntity identity = aDEntity.Identity as ADEntity; if (identity != null) { this.Validate(identity, engineIntrinsics); } return; } } else { return; } } else { return; } } }
internal virtual T Construct(ADEntity directoryObj) { if (base.CmdletSessionInfo != null) { T sessionInfo = Activator.CreateInstance <T>(); sessionInfo.IsSearchResult = true; sessionInfo.SessionInfo = directoryObj.SessionInfo; MappingTable <AttributeConverterEntry> item = ADFactoryBase <T> .AttributeTable[base.ConnectedStore]; foreach (AttributeConverterEntry value in item.Values) { if (!value.IsExtendedConverterDefined) { continue; } value.InvokeToExtendedConverter(sessionInfo, directoryObj, base.CmdletSessionInfo); } sessionInfo.TrackChanges = true; return(sessionInfo); } else { throw new ArgumentNullException(StringResources.SessionRequired); } }
internal virtual IEnumerable <ADEntity> GetADEntityFromXmlAttribute(ADEntity sourceEntity, string xmlAttributeName, string xmlAttributeObjectTypeName) { IEnumerable <ADEntity> aDEntities; List <ADEntity> aDEntities1 = new List <ADEntity>(); if (sourceEntity[xmlAttributeName] != null) { IEnumerator enumerator = sourceEntity[xmlAttributeName].GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; XmlDocument xmlDocument = new XmlDocument(); ADEntity aDEntity = new ADEntity(); string str = current as string; aDEntity.SessionInfo = sourceEntity.SessionInfo; if (str == null) { continue; } try { xmlDocument.LoadXml(this.RemoveInvalidXmlChars(str)); } catch (XmlException xmlException) { aDEntities = aDEntities1; return(aDEntities); } if (xmlDocument.ChildNodes.Count == 1) { if (xmlDocument.FirstChild.Name.Equals(xmlAttributeObjectTypeName, StringComparison.OrdinalIgnoreCase)) { IEnumerator enumerator1 = sourceEntity.PropertyNames.GetEnumerator(); try { while (enumerator1.MoveNext()) { string current1 = (string)enumerator1.Current; aDEntity.SetValue(current1, sourceEntity[current1]); } } finally { IDisposable disposable = enumerator1 as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (!aDEntity.Contains("sourceXmlAttribute")) { aDEntity.SetValue("sourceXmlAttribute", xmlAttributeName); } IEnumerator enumerator2 = xmlDocument.FirstChild.ChildNodes.GetEnumerator(); try { while (enumerator2.MoveNext()) { XmlNode xmlNodes = (XmlNode)enumerator2.Current; if (string.IsNullOrEmpty(xmlNodes.InnerText)) { continue; } aDEntity.SetValue(xmlNodes.Name, xmlNodes.InnerText); } } finally { IDisposable disposable1 = enumerator2 as IDisposable; if (disposable1 != null) { disposable1.Dispose(); } } aDEntities1.Add(aDEntity); } else { aDEntities = aDEntities1; return(aDEntities); } } else { aDEntities = aDEntities1; return(aDEntities); } } return(aDEntities1); } finally { IDisposable disposable2 = enumerator as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } return(aDEntities); } else { return(aDEntities1); } }
internal static void ToDirectoryCapMember(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData != null && directoryObj["msAuthz-MemberRulesInCentralAccessPolicy"] != null) { int count = extendedData.AddedValues.Count - extendedData.DeletedValues.Count; if (directoryObj["msAuthz-MemberRulesInCentralAccessPolicy"].Count + count > CentralAccessPolicyConstants.MaximumCARsPerCap) { object[] maximumCARsPerCap = new object[1]; maximumCARsPerCap[0] = CentralAccessPolicyConstants.MaximumCARsPerCap; throw new ArgumentOutOfRangeException("Members", string.Format(CultureInfo.CurrentCulture, StringResources.CAPMemberMaximumExceeded, maximumCARsPerCap)); } } AttributeConverters.ToDirectoryMultivalueObjectConvertor(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo, new MultiValueAttributeConvertorDelegate(AttributeConverters.MultiValueNoOpConvertor)); }
internal static void ToDirectoryFromSourceAttributeToDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { directoryObj.ForceRemove(directoryAttributes[0]); return; } else { ADSchemaObjectFactory <ADSchemaObject> aDSchemaObjectFactory = new ADSchemaObjectFactory <ADSchemaObject>(); aDSchemaObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADSchemaObject aDSchemaObject = new ADSchemaObject(); aDSchemaObject.Identity = extendedData.Value; ADObject extendedObjectFromIdentity = aDSchemaObjectFactory.GetExtendedObjectFromIdentity(aDSchemaObject, cmdletSessionInfo.ADRootDSE.SchemaNamingContext, ADClaimTypeFactory <T> .SchemaAttributeProperties); if (extendedObjectFromIdentity != null) { if (!extendedObjectFromIdentity.Contains("lDAPDisplayName") || !extendedObjectFromIdentity.Contains("attributeSyntax")) { object[] value = new object[1]; value[0] = extendedData.Value; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.SPCTInvalidSourceAttribute, value)); } else { string str = (string)extendedObjectFromIdentity["lDAPDisplayName"].Value; string value1 = (string)extendedObjectFromIdentity["attributeSyntax"].Value; HashSet <string> strs = new HashSet <string>(ADClaimTypeFactory <T> .BlockedAttributes, StringComparer.OrdinalIgnoreCase); if (!strs.Contains(str)) { if (!extendedObjectFromIdentity.Contains("systemFlags") || ((int)extendedObjectFromIdentity["systemFlags"].Value & ADClaimTypeFactory <T> .FLAG_ATTR_NOT_REPLICATED) == 0) { if (!extendedObjectFromIdentity.Contains("searchFlags") || ((int)extendedObjectFromIdentity["searchFlags"].Value & ADClaimTypeFactory <T> .RODCFilteredAttribute) == 0) { if (!extendedObjectFromIdentity.Contains("isDefunct") || !(bool)extendedObjectFromIdentity["isDefunct"].Value) { ADClaimValueType aDClaimValueType = ADClaimValueType.Invalid; HashSet <string> strs1 = new HashSet <string>(ADClaimTypeFactory <T> .ValidAttributeSyntaxInt, StringComparer.OrdinalIgnoreCase); HashSet <string> strs2 = new HashSet <string>(ADClaimTypeFactory <T> .ValidAttributeSyntaxString, StringComparer.OrdinalIgnoreCase); if (!strs2.Contains(value1)) { if (!strs1.Contains(value1)) { if (string.Compare(value1, ADClaimTypeFactory <T> .ValidAttributeSyntaxUInt, true, CultureInfo.InvariantCulture) != 0) { if (string.Compare(value1, ADClaimTypeFactory <T> .ValidBooleanAttributeSyntax, true, CultureInfo.InvariantCulture) != 0) { throw new ADException(StringResources.SPCTInvalidAttributeSyntax); } else { aDClaimValueType = ADClaimValueType.Boolean; } } else { aDClaimValueType = ADClaimValueType.UInt64; } } else { aDClaimValueType = ADClaimValueType.Int64; } } else { aDClaimValueType = ADClaimValueType.String; } directoryObj[directoryAttributes[0]].Value = extendedObjectFromIdentity.DistinguishedName; if (!directoryObj.Contains("msDS-ClaimValueType")) { directoryObj.Add("msDS-ClaimValueType", (long)aDClaimValueType); } else { long?nullable = (long?)(directoryObj["msDS-ClaimValueType"].Value as long?); if ((ADClaimValueType)nullable.Value != aDClaimValueType) { throw new ADException(StringResources.CTSourceAttributeValueTypeError); } } directoryObj.InternalProperties[directoryAttributes[0]].Value = str; return; } else { throw new ADException(StringResources.SPCTDefuctSourceAttr); } } else { throw new ADException(StringResources.SPCTRODCFilteredSourceAttr); } } else { throw new ADException(StringResources.SPCTNonREPLSourceAttrError); } } else { throw new ADException(StringResources.SPCTBlockedSourceAttribute); } } } else { throw new ADException(StringResources.SPCTInvalidSourceAttributeName); } } }
internal static void ToExtendedProtectedFromDeletion(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { ADObject aDObject = directoryObj as ADObject; if (aDObject == null) { object[] type = new object[2]; type[0] = "ToExtendedProtectedFromDeletion"; type[1] = directoryObj.GetType(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type)); } else { userObj.Add(extendedAttribute, ProtectedFromDeletionUtil.IsProtectedFromDeletion(aDObject, cmdletSessionInfo)); return; } }
internal virtual void InvokeToDirectoryConverter(ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { this._toDirectoryDelegate(base.ExtendedAttribute, this.DirectoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
private bool GetADDCBeginDiscoverCSRoutine() { bool flag; if (base.ParameterSetName == "DiscoverByService") { ADDiscoverDomainControllerOptions aDDiscoverDomainControllerOption = ADDiscoverDomainControllerOptions.None; ADDiscoverableService[] service = this._cmdletParameters.Service; ADMinimumDirectoryServiceVersion? item = (ADMinimumDirectoryServiceVersion?)(this._cmdletParameters["MinimumDirectoryServiceVersion"] as ADMinimumDirectoryServiceVersion?); string str = this._cmdletParameters["SiteName"] as string; string item1 = this._cmdletParameters["DomainName"] as string; if (this._cmdletParameters.GetSwitchParameterBooleanValue("NextClosestSite")) { aDDiscoverDomainControllerOption = aDDiscoverDomainControllerOption | ADDiscoverDomainControllerOptions.TryNextClosestSite; } if (this._cmdletParameters.GetSwitchParameterBooleanValue("ForceDiscover")) { aDDiscoverDomainControllerOption = aDDiscoverDomainControllerOption | ADDiscoverDomainControllerOptions.ForceDiscover; } if (this._cmdletParameters.GetSwitchParameterBooleanValue("AvoidSelf")) { aDDiscoverDomainControllerOption = aDDiscoverDomainControllerOption | ADDiscoverDomainControllerOptions.AvoidSelf; } if (this._cmdletParameters.GetSwitchParameterBooleanValue("Writable")) { aDDiscoverDomainControllerOption = aDDiscoverDomainControllerOption | ADDiscoverDomainControllerOptions.Writable; } try { ADEntity aDEntity = DomainControllerUtil.DiscoverDomainController(str, item1, service, aDDiscoverDomainControllerOption | ADDiscoverDomainControllerOptions.ReturnDnsName, item); try { ADDiscoverDomainControllerOptions aDDiscoverDomainControllerOption1 = aDDiscoverDomainControllerOption; aDDiscoverDomainControllerOption1 = aDDiscoverDomainControllerOption1 & (ADDiscoverDomainControllerOptions.AvoidSelf | ADDiscoverDomainControllerOptions.TryNextClosestSite | ADDiscoverDomainControllerOptions.Writable | ADDiscoverDomainControllerOptions.ReturnDnsName | ADDiscoverDomainControllerOptions.ReturnFlatName); ADEntity aDEntity1 = DomainControllerUtil.DiscoverDomainController(str, item1, service, aDDiscoverDomainControllerOption1 | ADDiscoverDomainControllerOptions.ReturnFlatName, item); if (aDEntity.InternalProperties.Contains("DiscoveryInternalPropertyDCAddress") && aDEntity1.InternalProperties.Contains("DiscoveryInternalPropertyDCAddress") && string.Equals((string)aDEntity.InternalProperties["DiscoveryInternalPropertyDCAddress"].Value, (string)aDEntity1.InternalProperties["DiscoveryInternalPropertyDCAddress"].Value)) { aDEntity.Add("Name", aDEntity1["Name"].Value); } } catch (ADException aDException1) { ADException aDException = aDException1; DebugLogger.LogError("GetADDomainController", aDException.ToString()); } CmdletSessionInfo cmdletSessionInfo = new CmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); ADDomainController aDDomainController = this._factory.Construct(aDEntity, new AttributeSetRequest(true)); base.WriteObject(aDDomainController); return(false); } catch (ADException aDException3) { ADException aDException2 = aDException3; int errorCode = aDException2.ErrorCode; base.WriteError(new ErrorRecord(aDException2, string.Concat("GetADDomainController:BeginProcessingOverride:DiscoverDC:", errorCode.ToString()), ErrorCategory.ObjectNotFound, null)); flag = false; } return(flag); } else { return(true); } }
internal static void ToExtendedFromDNToISTPEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string value = (string)directoryObj[directoryAttributes[0]].Value; value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500); string childName = ADPathModule.GetChildName(value, ADPathFormat.X500); ADInterSiteTransportProtocolType aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.IP; if (string.Compare("CN=IP", childName, StringComparison.OrdinalIgnoreCase) != 0) { aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.SMTP; } ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection((object)aDInterSiteTransportProtocolType); userObj.Add(extendedAttribute, aDPropertyValueCollection); }
internal static void ToDirectoryFromTopologyObjectNameListToDNList <F, O>(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) where F : ADFactory <O>, new() where O : ADEntity, new() { AttributeConverters.ToDirectoryMultivalueObjectConvertor(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo, new MultiValueAttributeConvertorDelegate(ADTopologyUtil.FromNameToTopologyDN <F, O>)); }
internal static void ToDirectoryFromSiteNameToDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500); AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADReplicationSiteFactory <ADReplicationSite>, ADReplicationSite>(str, null, extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToDirectoryFromServerNameToNTDSSettings(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADDirectoryServerFactory <ADDirectoryServer>, ADDirectoryServer>(cmdletSessionInfo.ADRootDSE.DefaultNamingContext, "NTDSSettingsObjectDN", extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToPolicyRuleStringFromRuleXml(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); } else { try { string str = ADClaimTransformPolicyFactory <T> .ParseRules(directoryObj[directoryAttributes[0]].Value as string); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(str); userObj.Add(extendedAttribute, aDPropertyValueCollection); } catch (Exception exception1) { Exception exception = exception1; if (exception as ADException != null || exception as XmlException != null) { object[] value = new object[3]; value[0] = directoryObj["distinguishedName"].Value; value[1] = exception.Message; value[2] = directoryObj[directoryAttributes[0]].Value; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.ClaimPolicyXmlWarning, value)); userObj.Add(extendedAttribute, new ADPropertyValueCollection()); } else { throw exception; } } } }
internal static void ToDirectoryPasswordProperties(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains("pwdProperties")) { throw new NotSupportedException(); } else { int value = (int)directoryObj["pwdProperties"].Value; bool item = (bool)extendedData[0]; int bit = PasswordPropertiesUtil.StringToBit(extendedAttribute); if (PasswordPropertiesUtil.IsInverseBit(bit)) { item = !item; } if (!item) { value = value & ~bit; } else { value = value | bit; } directoryObj.SetValue("pwdProperties", value); return; } }
internal static void ToExtendedGPLink(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); return; } else { string value = directoryObj[directoryAttributes[0]].Value as string; userObj.Add(extendedAttribute, GPLinkUtil.ConvertLinkedGroupPolicyObjects(value)); return; } }
internal static void ToExtendedFromIntToValueTypeEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (directoryObj.Contains(directoryAttributes[0])) { ADClaimValueType aDClaimValueType = ADClaimValueType.Invalid; long value = (long)directoryObj[directoryAttributes[0]].Value; if (!Enum.IsDefined(typeof(ADClaimValueType), value)) { object[] objArray = new object[2]; objArray[0] = directoryObj["distinguishedName"].Value; objArray[1] = value; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidClaimValueType, objArray)); } else { aDClaimValueType = (ADClaimValueType)value; } userObj.Add(extendedAttribute, new ADPropertyValueCollection((object)aDClaimValueType)); return; } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection); return; } }
internal static void ToExtendedPasswordProperties(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { bool flag; if (directoryObj.Contains(directoryAttributes[0])) { int value = (int)directoryObj[directoryAttributes[0]].Value; int bit = PasswordPropertiesUtil.StringToBit(extendedAttribute); if (!PasswordPropertiesUtil.IsInverseBit(bit)) { flag = (value & bit) != 0; } else { flag = (value & bit) == 0; } userObj.Add(extendedAttribute, flag); return; } else { return; } }
internal virtual void InvokeToExtendedConverter(ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { this._toExtendedDelegate(base.ExtendedAttribute, this.DirectoryAttributes, userObj, directoryObj, cmdletSessionInfo); }
private bool ADTargetScopeEnumerationServerPreProcessTargetCSRoutine() { object baseObject; ADSessionInfo sessionInfo = this.GetSessionInfo(); string item = this._cmdletParameters["Server"] as string; object[] objArray = this._cmdletParameters["Target"] as object[]; for (int i = 0; i < (int)objArray.Length; i++) { object obj = objArray[i]; if (obj as PSObject == null) { baseObject = obj; } else { baseObject = ((PSObject)obj).BaseObject; } string str = baseObject as string; ADEntity aDEntity = baseObject as ADEntity; if (aDEntity == null) { ADScopeType?nullable = (ADScopeType?)(this._cmdletParameters["Scope"] as ADScopeType?); ADScopeType valueOrDefault = nullable.GetValueOrDefault(); if (nullable.HasValue) { switch (valueOrDefault) { case ADScopeType.Server: { this.AddSessionsMatchingServerName(str); break; } case ADScopeType.Domain: { if (item == null) { ADDiscoverableService[] aDDiscoverableServiceArray = new ADDiscoverableService[1]; aDDiscoverableServiceArray[0] = ADDiscoverableService.ADWS; ADMinimumDirectoryServiceVersion?nullable1 = null; ADEntity aDEntity1 = DomainControllerUtil.DiscoverDomainController(null, str, aDDiscoverableServiceArray, ADDiscoverDomainControllerOptions.ReturnDnsName, nullable1); this.SetPipelinedSessionInfo(new ADSessionInfo(aDEntity1["HostName"].Value as string)); } ADDomainFactory <ADDomain> aDDomainFactory = new ADDomainFactory <ADDomain>(); aDDomainFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo()); ADDomain extendedObjectFromIdentity = aDDomainFactory.GetExtendedObjectFromIdentity(new ADDomain(str), this.GetRootDSE().DefaultNamingContext); this.AddSessionsFromDomain(extendedObjectFromIdentity); if (item != null) { break; } this.SetPipelinedSessionInfo(sessionInfo); break; } case ADScopeType.Forest: { if (item != null) { ADForestFactory <ADForest> aDForestFactory = new ADForestFactory <ADForest>(); aDForestFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo()); try { aDForestFactory.GetDirectoryObjectFromIdentity(new ADForest(str), null); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; base.WriteError(this.ConstructErrorRecord(aDIdentityNotFoundException)); break; } } else { ADDiscoverableService[] aDDiscoverableServiceArray1 = new ADDiscoverableService[1]; aDDiscoverableServiceArray1[0] = ADDiscoverableService.ADWS; ADMinimumDirectoryServiceVersion?nullable2 = null; ADEntity aDEntity2 = DomainControllerUtil.DiscoverDomainController(null, str, aDDiscoverableServiceArray1, ADDiscoverDomainControllerOptions.ReturnDnsName, nullable2); this.SetPipelinedSessionInfo(new ADSessionInfo(aDEntity2["HostName"].Value as string)); } this.AddSessionsFromConnectedForest(); if (item != null) { break; } this.SetPipelinedSessionInfo(sessionInfo); break; } case ADScopeType.Site: { this.AddSessionsMatchingSiteName(str); break; } } } } else { if (aDEntity.IsSearchResult) { this.SetPipelinedSessionInfo(aDEntity.SessionInfo); if (aDEntity as ADForest == null) { if (aDEntity as ADDomain == null) { if (aDEntity as ADDirectoryServer == null) { if (aDEntity as ADReplicationSite == null) { object[] type = new object[2]; type[0] = aDEntity.GetType(); type[1] = "Target"; base.WriteErrorBuffered(this.ConstructErrorRecord(new ParameterBindingException(string.Format(CultureInfo.CurrentCulture, StringResources.UnsupportedParameterType, type)))); } else { ADReplicationSite aDReplicationSite = (ADReplicationSite)aDEntity; this.AddSessionFromSiteDN(aDReplicationSite.DistinguishedName); } } else { ADDirectoryServer aDDirectoryServer = (ADDirectoryServer)aDEntity; this._sessionPipe.AddLast(new ADSessionInfo(aDDirectoryServer["HostName"].Value as string)); } } else { ADDomain aDDomain = (ADDomain)aDEntity; this.AddSessionsFromDomain(aDDomain); } } else { this.AddSessionsFromConnectedForest(); } this.SetPipelinedSessionInfo(sessionInfo); } else { base.WriteErrorBuffered(this.ConstructErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.OnlySearchResultsSupported, new object[0])))); } } } return(true); }
internal static void ToRuleXmlFromPolicyString(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { directoryObj.ForceRemove(directoryAttributes[0]); return; } else { object[] value = new object[1]; value[0] = extendedData.Value; string str = string.Format(CultureInfo.InvariantCulture, ADClaimTransformPolicyFactory <T> .RuleXml, value); RulesParser rulesParser = new RulesParser(); try { rulesParser.ValidateRules(str); } catch (XmlParseException xmlParseException1) { XmlParseException xmlParseException = xmlParseException1; object[] message = new object[2]; message[0] = extendedData.Value; message[1] = xmlParseException.Message; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.XmlFormattingError, message)); } catch (PolicyValidationException policyValidationException1) { PolicyValidationException policyValidationException = policyValidationException1; object[] objArray = new object[2]; objArray[0] = extendedData.Value; objArray[1] = policyValidationException.Message; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.RuleValidationFailure, objArray)); } directoryObj[directoryAttributes[0]].Value = str; return; } }
internal override T Construct(ADEntity directoryObj, AttributeSetRequest requestedAttributes) { requestedAttributes = base.ConstructAttributeSetRequest(null); return(base.Construct(directoryObj, requestedAttributes)); }
internal static void ToDirectoryFromNameToManagedByDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADPrincipalFactory <ADPrincipal>, ADPrincipal>(cmdletSessionInfo.ADRootDSE.DefaultNamingContext, null, extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToCompatibleResourceTypes(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains("msDS-ClaimValueType") || !directoryObj.Contains("msDS-ClaimIsValueSpaceRestricted")) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection); return; } else { long value = (long)directoryObj["msDS-ClaimValueType"].Value; bool flag = directoryObj.Contains("msDS-ClaimPossibleValues"); IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-ClaimValueType", value); IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-IsPossibleValuesPresent", flag); IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = aDOPathNode; aDOPathNodeArray[1] = aDOPathNode1; IADOPathNode aDOPathNode2 = ADOPathUtil.CreateAndClause(aDOPathNodeArray); ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>(); aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo); string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500); int? nullable = null; int? nullable1 = null; IEnumerable <ADResourcePropertyValueType> extendedObjectFromFilter = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromFilter(aDOPathNode2, str, ADSearchScope.OneLevel, null, nullable, nullable1, false); List <string> strs = new List <string>(); foreach (ADResourcePropertyValueType aDResourcePropertyValueType in extendedObjectFromFilter) { strs.Add(aDResourcePropertyValueType.Name); } userObj.Add(extendedAttribute, new ADPropertyValueCollection(strs)); return; } }