internal override T GetExtendedObjectFromDN(string distinguishedName, ICollection <string> propertiesToFetch, bool showDeleted) { string str = ADPathModule.MakePath(base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Partitions", ADPathFormat.X500); if (ADPathModule.ComparePath(str, distinguishedName, ADPathFormat.X500)) { return(this.GetExtendedForestObjectUsingCurrentSession(propertiesToFetch, showDeleted)); } else { object[] objArray = new object[2]; objArray[0] = str; objArray[1] = distinguishedName; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ConnectedToWrongForest, objArray)); } }
internal static ADObject GetObjectFromIdentitySearcher(ADObjectSearcher searcher, ADEntity identityObj, string searchRoot, AttributeSetRequest attrs, CmdletSessionInfo cmdletSessionInfo, out string[] warningMessages) { ADObject aDObject; bool flag = false; warningMessages = new string[0]; using (searcher) { searcher.Properties.AddRange(attrs.DirectoryAttributes); DebugLogger.LogInfo("ADFactoryUtil", string.Format("GetObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", searcher.Filter.GetLdapFilterString(), searcher.SearchRoot)); aDObject = searcher.FindOne(out flag); if (aDObject != null) { if (flag) { throw new ADMultipleMatchingIdentitiesException(StringResources.MultipleMatches); } } else { DebugLogger.LogInfo("ADFactoryUtil", string.Format("GetObjectFromIdentity: Identity not found.", new object[0])); object[] str = new object[2]; str[0] = identityObj.ToString(); str[1] = searchRoot; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str)); } } string str1 = ADForestPartitionInfo.ExtractPartitionInfo(cmdletSessionInfo.ADRootDSE, aDObject.DistinguishedName, false); if (cmdletSessionInfo.CmdletParameters.Contains("Partition")) { string item = cmdletSessionInfo.CmdletParameters["Partition"] as string; if (!ADPathModule.ComparePath(item, str1, ADPathFormat.X500)) { string[] strArrays = new string[1]; object[] objArray = new object[3]; objArray[0] = identityObj.ToString(); objArray[1] = str1; objArray[2] = item; strArrays[0] = string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInWrongPartition, objArray); warningMessages = strArrays; } } cmdletSessionInfo.DefaultPartitionPath = str1; return(aDObject); }
private static bool IsValidPartitionDN(ADRootDSE rootDSE, string partitionDN, bool refreshForestPartitionList) { bool flag; if (rootDSE != null) { if (partitionDN != null) { if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC || !partitionDN.Equals(string.Empty)) { IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList); IEnumerator <string> enumerator = validPartitionList.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { string current = enumerator.Current; if (!ADPathModule.ComparePath(partitionDN, current, ADPathFormat.X500)) { continue; } flag = true; return(flag); } return(false); } return(flag); } else { return(true); } } else { throw new ArgumentNullException("partitionDN"); } } else { throw new ArgumentNullException("rootDSE"); } }