private bool SetADPrincipalGroupMembershipProcessCSRoutine() { if (this._cmdletParameters.Contains("Identity")) { ADPrincipal item = this._cmdletParameters["Identity"] as ADPrincipal; this.SetPipelinedSessionInfo(item.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); base.ValidateParameters(); this.ValidateMemberOfParameter(); try { ADPrincipal extendedObjectFromIdentity = this._factory.GetExtendedObjectFromIdentity(item, cmdletSessionInfo.DefaultPartitionPath); this._validExtendedPrincipalList.Add(extendedObjectFromIdentity); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; base.ThrowTerminatingError(ADUtilities.GetErrorRecord(aDIdentityNotFoundException, "SetADPrincipalGroupMembership:ProcessRecordOverride", item)); } return(true); } else { object[] objArray = new object[1]; objArray[0] = "Identity"; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray)); } }
private bool SetADComputerServiceAccountBeginCSRoutine() { object item = this._cmdletParameters["ServiceAccount"]; ADServiceAccount[] aDServiceAccountArray = item as ADServiceAccount[]; if (aDServiceAccountArray == null) { ADServiceAccount aDServiceAccount = item as ADServiceAccount; if (aDServiceAccount != null) { ADServiceAccount[] aDServiceAccountArray1 = new ADServiceAccount[1]; aDServiceAccountArray1[0] = aDServiceAccount; aDServiceAccountArray = aDServiceAccountArray1; } } if (aDServiceAccountArray == null) { ArgumentException argumentException = new ArgumentException(StringResources.ObjectNotFound); base.ThrowTerminatingError(new ErrorRecord(argumentException, "SetADComputerServiceAccount:BeginProcessingOverride", ErrorCategory.ObjectNotFound, this)); } else { List <string> strs = new List <string>(); List <ADServiceAccount> aDServiceAccounts = new List <ADServiceAccount>(); Hashtable hashtables = new Hashtable(); ADServiceAccountFactory <ADServiceAccount> aDServiceAccountFactory = new ADServiceAccountFactory <ADServiceAccount>(); ADServiceAccount[] aDServiceAccountArray2 = aDServiceAccountArray; for (int i = 0; i < (int)aDServiceAccountArray2.Length; i++) { ADServiceAccount aDServiceAccount1 = aDServiceAccountArray2[i]; base.SetPipelinedSessionInfo(aDServiceAccount1.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDServiceAccountFactory.SetCmdletSessionInfo(cmdletSessionInfo); try { ADObject directoryObjectFromIdentity = aDServiceAccountFactory.GetDirectoryObjectFromIdentity(aDServiceAccount1, cmdletSessionInfo.DefaultPartitionPath); strs.Add(directoryObjectFromIdentity.DistinguishedName); this._resolvedServiceAccountList.Add(directoryObjectFromIdentity); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADComputerServiceAccount", aDIdentityNotFoundException.ToString()); aDServiceAccounts.Add(aDServiceAccount1); } } if (aDServiceAccounts.Count > 0) { ArgumentException argumentException1 = new ArgumentException(StringResources.ObjectNotFound); base.ThrowTerminatingError(new ErrorRecord(argumentException1, "SetADComputerServiceAccount:BeginProcessingOverride", ErrorCategory.ObjectNotFound, aDServiceAccounts.ToArray())); } hashtables.Add(this._modifyOpString, strs.ToArray()); this._cmdletParameters.RemoveParameter("ServiceAccount"); this._cmdletParameters["ServiceAccount"] = new ADMultivalueHashtableParameter <string>(hashtables); } return(true); }
private void ValidateSubjectsAndAddToList() { object item = this._cmdletParameters["Subjects"]; ADPrincipal[] aDPrincipalArray = item as ADPrincipal[]; if (aDPrincipalArray == null) { ADPrincipal aDPrincipal = item as ADPrincipal; if (aDPrincipal != null) { ADPrincipal[] aDPrincipalArray1 = new ADPrincipal[1]; aDPrincipalArray1[0] = aDPrincipal; aDPrincipalArray = aDPrincipalArray1; } } ADPrincipalFactory <ADPrincipal> aDPrincipalFactory = new ADPrincipalFactory <ADPrincipal>(); if (aDPrincipalArray[0].IsSearchResult) { this.SetPipelinedSessionInfo(aDPrincipalArray[0].SessionInfo); } CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDPrincipalFactory.SetCmdletSessionInfo(cmdletSessionInfo); if (aDPrincipalArray != null) { new Hashtable(); ADPrincipal[] aDPrincipalArray2 = aDPrincipalArray; for (int i = 0; i < (int)aDPrincipalArray2.Length; i++) { ADPrincipal aDPrincipal1 = aDPrincipalArray2[i]; try { ADObject directoryObjectFromIdentity = aDPrincipalFactory.GetDirectoryObjectFromIdentity(aDPrincipal1, cmdletSessionInfo.DefaultPartitionPath); this._appliesToDNList.Add(directoryObjectFromIdentity.DistinguishedName); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADFineGrainedPasswordPolicySubject", aDIdentityNotFoundException.ToString()); base.ThrowTerminatingError(ADUtilities.GetErrorRecord(aDIdentityNotFoundException, "SetADFineGrainedPasswordPolicySubject:ValidateSubjectsAndAddToList", aDPrincipal1)); } } } }
internal static string GetWellKnownGuidDN(ADSessionInfo adSession, string partitionDN, string wellKnownGuid) { string distinguishedName; if (partitionDN != null) { ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(adSession); try { try { aDObjectSearcher.SearchRoot = string.Format("<WKGUID={0},{1}>", wellKnownGuid, partitionDN); aDObjectSearcher.Scope = ADSearchScope.Base; aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); ADObject aDObject = aDObjectSearcher.FindOne(); if (aDObject == null) { distinguishedName = null; } else { distinguishedName = aDObject.DistinguishedName; } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("Utils", string.Format("Error in searching for WKGUID {0}", aDIdentityNotFoundException.Message)); distinguishedName = null; } } finally { aDObjectSearcher.Dispose(); } return(distinguishedName); } else { return(null); } }
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); }
private void ValidateMembersParameter() { bool flag; if (!this._isMembersValidated) { object item = this._cmdletParameters["Members"]; ADPrincipal[] aDPrincipalArray = item as ADPrincipal[]; if (aDPrincipalArray == null) { ADPrincipal aDPrincipal = item as ADPrincipal; if (aDPrincipal != null) { ADPrincipal[] aDPrincipalArray1 = new ADPrincipal[1]; aDPrincipalArray1[0] = aDPrincipal; aDPrincipalArray = aDPrincipalArray1; } } if (aDPrincipalArray != null) { List <string> strs = new List <string>(); Hashtable hashtables = new Hashtable(); ADPrincipalFactory <ADPrincipal> aDPrincipalFactory = new ADPrincipalFactory <ADPrincipal>(); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDPrincipalFactory.SetCmdletSessionInfo(cmdletSessionInfo); if (cmdletSessionInfo.ConnectedADServerType != ADServerType.ADDS) { flag = false; } else { flag = this._operationType == SetADGroupMemberOperationType.RemoveGroupMember; } bool flag1 = flag; Dictionary <SecurityIdentifier, string> securityIdentifiers = new Dictionary <SecurityIdentifier, string>(); IADOPathNode aDOPathNode = null; SecurityIdentifier value = null; if (flag1) { ADGroup aDGroup = (ADGroup)this._cmdletParameters["Identity"]; if (!aDGroup.IsSearchResult) { ADObject directoryObjectFromIdentity = aDPrincipalFactory.GetDirectoryObjectFromIdentity(aDGroup, cmdletSessionInfo.DefaultPartitionPath); value = (SecurityIdentifier)directoryObjectFromIdentity["objectSid"].Value; } else { value = aDGroup.SID; } } ADPrincipal[] aDPrincipalArray2 = aDPrincipalArray; for (int i = 0; i < (int)aDPrincipalArray2.Length; i++) { ADPrincipal aDPrincipal1 = aDPrincipalArray2[i]; SecurityIdentifier sID = null; string distinguishedName = null; try { if (!aDPrincipal1.IsSearchResult) { ADObject aDObject = aDPrincipalFactory.GetDirectoryObjectFromIdentity(aDPrincipal1, cmdletSessionInfo.DefaultPartitionPath); sID = (SecurityIdentifier)aDObject["objectSid"].Value; distinguishedName = (string)aDObject["distinguishedName"].Value; } else { sID = aDPrincipal1.SID; distinguishedName = aDPrincipal1.DistinguishedName; } if (distinguishedName != null) { if (sID == null) { object[] objArray = new object[2]; objArray[0] = "objectSid"; objArray[1] = distinguishedName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.AttributeNotFoundOnObject, objArray)); } } else { object[] identifyingString = new object[2]; identifyingString[0] = "distinguishedName"; identifyingString[1] = aDPrincipal1.IdentifyingString; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.AttributeNotFoundOnObject, identifyingString)); } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADGroupMember", aDIdentityNotFoundException.ToString()); base.ThrowTerminatingError(new ErrorRecord(aDIdentityNotFoundException, "SetADGroupMember.ValidateMembersParameter", ErrorCategory.ObjectNotFound, aDPrincipal1)); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; DebugLogger.LogError("SetADGroupMember", argumentException.ToString()); base.ThrowTerminatingError(new ErrorRecord(argumentException, "SetADGroupMember.ValidateMembersParameter", ErrorCategory.ReadError, aDPrincipal1)); } if (!flag1 || value.IsEqualDomainSid(sID)) { strs.Add(Utils.ConvertSIDToStringizedSid(sID)); } else { IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectSid", sID); if (aDOPathNode != null) { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = aDOPathNode; aDOPathNodeArray[1] = aDOPathNode1; aDOPathNode = ADOPathUtil.CreateOrClause(aDOPathNodeArray); } else { aDOPathNode = aDOPathNode1; } securityIdentifiers.Add(sID, distinguishedName); } } if (aDOPathNode != null) { using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this.GetSessionInfo())) { IADOPathNode aDOPathNode2 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "foreignSecurityPrincipal"); aDObjectSearcher.SearchRoot = this.GetRootDSE().DefaultNamingContext; IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2]; aDOPathNodeArray1[0] = aDOPathNode2; aDOPathNodeArray1[1] = aDOPathNode; aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray1); aDObjectSearcher.Properties.Add("objectSid"); foreach (ADObject aDObject1 in aDObjectSearcher.FindAll()) { SecurityIdentifier securityIdentifier = (SecurityIdentifier)aDObject1["objectSid"].Value; if (!securityIdentifiers.ContainsKey(securityIdentifier)) { continue; } strs.Add(Utils.ConvertSIDToStringizedSid(securityIdentifier)); securityIdentifiers.Remove(securityIdentifier); } foreach (string str in securityIdentifiers.Values) { strs.Add(str); } } } if (this._operationType != SetADGroupMemberOperationType.AddGroupMember) { if (this._operationType == SetADGroupMemberOperationType.RemoveGroupMember) { hashtables.Add(PropertyModifyOp.Remove.ToString(), strs.ToArray()); } } else { hashtables.Add(PropertyModifyOp.Add.ToString(), strs.ToArray()); } this._cmdletParameters.RemoveParameter("Members"); this._cmdletParameters["Members"] = new ADMultivalueHashtableParameter <string>(hashtables); this._isMembersValidated = true; } return; } else { return; } }
protected internal virtual void WritePropertiesToOutput(O inputIdentity, ADEntity constructedIdentityObject) { bool flag = false; if (constructedIdentityObject == null) { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("Identity: {0} not found", inputIdentity)); } else { CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); ADPropertyValueCollection item = constructedIdentityObject[this.SourceProperty]; RO rO = Activator.CreateInstance <RO>(); if (item == null) { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("Could not find property: {0} for identity: {1}", this.SourceProperty, inputIdentity)); return; } else { List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>(this._pageSize); foreach (string str in item) { try { string str1 = this.ExtractIdentityInfoFromSourcePropertyValue(str, out flag); if (str1 != null) { rO.Identity = str1; if (!flag) { RO extendedObjectFromIdentity = this._returnObjectFactory.GetExtendedObjectFromIdentity(rO, cmdletSessionInfo.DefaultPartitionPath); base.WriteObject(extendedObjectFromIdentity); } else { IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", Utils.EscapeDNForFilter(str1)); aDOPathNodes.Add(aDOPathNode); if (aDOPathNodes.Count >= this._pageSize) { this.WriteObjectsInBatch(aDOPathNodes); aDOPathNodes.Clear(); } } } else { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("ExtractIdentityInfoFromSourcePropertyValue returned NULL for propertyValue: {0} - skipping this value", str)); } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; base.WriteError(ADUtilities.GetErrorRecord(aDIdentityNotFoundException, "ADGetPropertiesCmdletBase:WritePropertiesToOutput", str)); } } if (aDOPathNodes.Count > 0) { this.WriteObjectsInBatch(aDOPathNodes); aDOPathNodes.Clear(); return; } } } }
private void ValidateMemberOfParameter() { ADGroup extendedObjectFromIdentity; if (!this._isMemberOfValidated) { this._validExtendedGroupPartitionPairList = new List <SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair>(); object item = this._cmdletParameters["MemberOf"]; ADPrincipal[] aDPrincipalArray = item as ADGroup[]; if (aDPrincipalArray == null) { ADGroup aDGroup = item as ADGroup; if (aDGroup != null) { ADGroup[] aDGroupArray = new ADGroup[1]; aDGroupArray[0] = aDGroup; aDPrincipalArray = aDGroupArray; } } if (aDPrincipalArray != null) { new Hashtable(); ADGroupFactory <ADGroup> aDGroupFactory = new ADGroupFactory <ADGroup>(); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDGroupFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADPrincipal[] aDPrincipalArray1 = aDPrincipalArray; for (int i = 0; i < (int)aDPrincipalArray1.Length; i++) { ADGroup aDGroup1 = (ADGroup)aDPrincipalArray1[i]; try { if (!aDGroup1.IsSearchResult) { extendedObjectFromIdentity = aDGroupFactory.GetExtendedObjectFromIdentity(aDGroup1, cmdletSessionInfo.DefaultPartitionPath); this._validExtendedGroupPartitionPairList.Add(new SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair(extendedObjectFromIdentity)); } else { extendedObjectFromIdentity = aDGroup1; using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(extendedObjectFromIdentity.SessionInfo)) { ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(); string str = ADForestPartitionInfo.ExtractAndValidatePartitionInfo(rootDSE, extendedObjectFromIdentity.DistinguishedName); this._validExtendedGroupPartitionPairList.Add(new SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair(extendedObjectFromIdentity, str)); } } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADPrincipalGroupMembership", aDIdentityNotFoundException.ToString()); base.ThrowTerminatingError(new ErrorRecord(aDIdentityNotFoundException, "SetADPrincipalGroupMembership:ValidateMemberOfParameter", ErrorCategory.ObjectNotFound, aDGroup1)); } } } this._isMemberOfValidated = true; return; } else { return; } }
private bool SetADDCPrpBeginCSRoutine() { SecurityIdentifier value; ADPrincipal[] item = null; if (base.ParameterSetName != "AllowedPRP") { if (base.ParameterSetName == "DeniedPRP") { item = this._cmdletParameters["DeniedList"] as ADPrincipal[]; } } else { item = this._cmdletParameters["AllowedList"] as ADPrincipal[]; } if (item != null) { List <string> strs = new List <string>(); ADPrincipalFactory <ADPrincipal> aDPrincipalFactory = new ADPrincipalFactory <ADPrincipal>(); ADPrincipal[] aDPrincipalArray = item; for (int i = 0; i < (int)aDPrincipalArray.Length; i++) { ADPrincipal aDPrincipal = aDPrincipalArray[i]; base.SetPipelinedSessionInfo(aDPrincipal.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDPrincipalFactory.SetCmdletSessionInfo(cmdletSessionInfo); try { if (!aDPrincipal.IsSearchResult) { ADObject directoryObjectFromIdentity = aDPrincipalFactory.GetDirectoryObjectFromIdentity(aDPrincipal, cmdletSessionInfo.DefaultPartitionPath); value = (SecurityIdentifier)directoryObjectFromIdentity["objectSid"].Value; } else { value = aDPrincipal.SID; } if (value != null) { string stringizedSid = Utils.ConvertSIDToStringizedSid(value); strs.Add(stringizedSid); } else { object[] distinguishedName = new object[2]; distinguishedName[0] = "objectSid"; distinguishedName[1] = aDPrincipal.DistinguishedName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.AttributeNotFoundOnObject, distinguishedName)); } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADDCPasswordReplicationPolicy", aDIdentityNotFoundException.ToString()); base.ThrowTerminatingError(new ErrorRecord(aDIdentityNotFoundException, "SetADDCPasswordReplicationPolicy:BeginProcessing", ErrorCategory.ReadError, aDPrincipal)); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; DebugLogger.LogError("SetADDCPasswordReplicationPolicy", argumentException.ToString()); base.ThrowTerminatingError(new ErrorRecord(argumentException, "SetADDCPasswordReplicationPolicy:BeginProcessing", ErrorCategory.ReadError, aDPrincipal)); } } this._principalsToAddOrRemove = new Hashtable(); if (base.ParameterSetName != "AllowedPRP") { if (base.ParameterSetName == "DeniedPRP") { this._principalsToAddOrRemove.Add("msDS-NeverRevealGroup", strs.ToArray()); } } else { this._principalsToAddOrRemove.Add("msDS-RevealOnDemandGroup", strs.ToArray()); } } return(true); }
internal static IADOPathNode ToSearchFromADEntityToAttributeValue <F, O>(string searchBase, string attributeName, string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) where F : ADFactory <O>, new() where O : ADEntity, new() { ADEntity extendedObjectFromIdentity; IADOPathNode binaryADOPathNode; BinaryADOPathNode binaryADOPathNode1 = filterClause as BinaryADOPathNode; if (binaryADOPathNode1 == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { if (binaryADOPathNode1.Operator == ADOperator.Eq || binaryADOPathNode1.Operator == ADOperator.Ne) { IDataNode rightNode = binaryADOPathNode1.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode(null); O dataObject = (O)(rightNode.DataObject as O); if (dataObject == null) { string str = rightNode.DataObject as string; if (str != null) { dataObject = Activator.CreateInstance <O>(); dataObject.Identity = str; } } if (dataObject == null) { object[] objArray = new object[2]; objArray[0] = rightNode.DataObject.ToString(); objArray[1] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterInvalidValue, objArray)); } else { F f = Activator.CreateInstance <F>(); f.SetCmdletSessionInfo(cmdletSessionInfo); try { if (attributeName != null) { HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); strs.Add(attributeName); extendedObjectFromIdentity = f.GetExtendedObjectFromIdentity(dataObject, searchBase, strs, false); objectADOPathNode.DataObject = (string)extendedObjectFromIdentity[attributeName].Value; } else { extendedObjectFromIdentity = f.GetDirectoryObjectFromIdentity(dataObject, searchBase); objectADOPathNode.DataObject = (string)extendedObjectFromIdentity["DistinguishedName"].Value; } binaryADOPathNode = new BinaryADOPathNode(binaryADOPathNode1.Operator, propertyADOPathNode, objectADOPathNode); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; object[] message = new object[2]; message[0] = extendedAttributeName; message[1] = aDIdentityNotFoundException.Message; throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInExtendedAttributeCannotBeResolved, message), aDIdentityNotFoundException); } catch (ADIdentityResolutionException aDIdentityResolutionException1) { ADIdentityResolutionException aDIdentityResolutionException = aDIdentityResolutionException1; object[] message1 = new object[2]; message1[0] = extendedAttributeName; message1[1] = aDIdentityResolutionException.Message; throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInExtendedAttributeCannotBeResolved, message1), aDIdentityResolutionException); } return(binaryADOPathNode); } } } else { object[] str1 = new object[2]; ADOperator[] aDOperatorArray = new ADOperator[2]; aDOperatorArray[1] = ADOperator.Ne; str1[0] = SearchConverters.ConvertOperatorListToString(aDOperatorArray); str1[1] = extendedAttributeName; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, str1)); } } }