internal string[] ConstructPropertyListFromSet(AttributeSet set) { AttributeSetRequest attributeSetRequest = this._factory.ConstructAttributeSetRequest(set); List <string> strs = new List <string>(attributeSetRequest.ExtendedAttributes); return(strs.ToArray()); }
internal override AttributeSetRequest ConstructAttributeSetRequest(ICollection <string> requestedExtendedAttr) { AttributeSetRequest attributeSetRequest = base.ConstructAttributeSetRequest(requestedExtendedAttr); attributeSetRequest.DirectoryAttributes.Add("groupType"); return(attributeSetRequest); }
internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted) { ADObject aDSessionInfo; this.ValidateIdentity(identityObj); string str = string.Concat("CN=Partitions,", base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext); ADObjectSearcher structuralObjectFilter = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base); using (structuralObjectFilter) { AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(null); structuralObjectFilter.Properties.AddRange(attributeSetRequest.DirectoryAttributes); structuralObjectFilter.Filter = this.StructuralObjectFilter; DebugLogger.LogInfo("ADForestFactory", string.Format("GetDirectoryObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", structuralObjectFilter.Filter.GetLdapFilterString(), structuralObjectFilter.SearchRoot)); aDSessionInfo = structuralObjectFilter.FindOne(); if (aDSessionInfo == null) { DebugLogger.LogInfo("ADForestFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0])); object[] objArray = new object[2]; objArray[0] = identityObj.ToString(); objArray[1] = structuralObjectFilter.SearchRoot; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray)); } } aDSessionInfo.TrackChanges = true; aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; return(aDSessionInfo); }
internal override AttributeSetRequest ConstructAttributeSetRequest(ICollection <string> requestedExtendedAttr) { AttributeSetRequest attributeSetRequest = base.ConstructAttributeSetRequest(requestedExtendedAttr); ADSchema aDSchema = new ADSchema(base.CmdletSessionInfo.ADSessionInfo); if (!aDSchema.SchemaProperties.ContainsKey("msDS-hasFullReplicaNCs")) { attributeSetRequest.DirectoryAttributes.Remove("msDS-hasFullReplicaNCs"); } return(attributeSetRequest); }
internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted) { ADObject aDObject; ADDefaultDomainPasswordPolicy aDDefaultDomainPasswordPolicy = identityObj; if (aDDefaultDomainPasswordPolicy != null) { if (base.CmdletSessionInfo != null) { AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(propertiesToFetch); IADOPathNode[] structuralObjectFilter = new IADOPathNode[2]; structuralObjectFilter[0] = this.StructuralObjectFilter; structuralObjectFilter[1] = this.BuildIdentityFilter(identityObj); IADOPathNode aDOPathNode = ADOPathUtil.CreateAndClause(structuralObjectFilter); string defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext; ADSearchScope aDSearchScope = ADSearchScope.Base; ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, aDSearchScope, showDeleted); using (aDObjectSearcher) { aDObjectSearcher.Filter = aDOPathNode; aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes); DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1} scope: {2}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot, aDObjectSearcher.Scope)); aDObject = aDObjectSearcher.FindOne(); if (aDObject == null) { DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Identity not found", new object[0])); object[] str = new object[2]; str[0] = identityObj.ToString(); str[1] = aDObjectSearcher.SearchRoot; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str)); } } T aDSessionInfo = this.Construct(aDObject, attributeSetRequest); aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; return(aDSessionInfo); } else { throw new ArgumentNullException(StringResources.SessionRequired); } } else { object[] type = new object[2]; type[0] = "GetExtendedObjectFromIdentity"; type[1] = identityObj.GetType(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type)); } }
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); }
internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted) { ADObject aDSessionInfo; if (base.CmdletSessionInfo != null) { string defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext; ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, ADSearchScope.Base); using (aDObjectSearcher) { AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(null); aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes); IADOPathNode[] structuralObjectFilter = new IADOPathNode[2]; structuralObjectFilter[0] = this.StructuralObjectFilter; structuralObjectFilter[1] = this.BuildIdentityFilter(identityObj); aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(structuralObjectFilter); DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("GetDirectoryObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot)); aDSessionInfo = aDObjectSearcher.FindOne(); if (aDSessionInfo == null) { DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0])); object[] str = new object[2]; str[0] = identityObj.ToString(); str[1] = aDObjectSearcher.SearchRoot; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str)); } } if (!aDSessionInfo.ObjectClass.Equals("domainDNS", StringComparison.OrdinalIgnoreCase)) { object[] objArray = new object[2]; objArray[0] = identityObj.ToString(); objArray[1] = defaultNamingContext; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray)); } else { aDSessionInfo.TrackChanges = true; aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; return(aDSessionInfo); } } else { throw new ArgumentNullException(StringResources.SessionRequired); } }
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; }
internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted) { ADObject aDObject = identityObj; if (aDObject != null) { if (base.CmdletSessionInfo != null) { if (aDObject.IsSearchResult && aDObject.Contains("isDeleted")) { showDeleted = true; } ADObjectSearcher aDObjectSearcherFromIdentity = ADFactoryUtil.GetADObjectSearcherFromIdentity(identityObj, searchRoot, showDeleted, this.StructuralObjectFilter, this.BuildIdentityFilter(identityObj), this.IdentityResolvers, base.CmdletSessionInfo); AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(null); string[] strArrays = new string[0]; ADObject objectFromIdentitySearcher = ADFactoryUtil.GetObjectFromIdentitySearcher(aDObjectSearcherFromIdentity, identityObj, searchRoot, attributeSetRequest, base.CmdletSessionInfo, out strArrays); objectFromIdentitySearcher.TrackChanges = true; objectFromIdentitySearcher.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str = strArrays1[i]; base.CmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(str); } return(objectFromIdentitySearcher); } else { throw new ArgumentNullException(StringResources.SessionRequired); } } else { object[] type = new object[2]; type[0] = "GetDirectoryObjectFromIdentity"; type[1] = identityObj.GetType(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type)); } }
internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted) { ADObject aDObject = null; ADObject aDObject1 = null; ADObject aDObject2 = null; T t; string nTDSSettingsDN = this.ResolveIdentityToNTDSSettingsDN(identityObj, null, false, out aDObject, out aDObject1, out aDObject2); if (nTDSSettingsDN != null) { using (ADTopologyManagement aDTopologyManagement = new ADTopologyManagement(base.CmdletSessionInfo.ADSessionInfo)) { string[] strArrays = new string[1]; strArrays[0] = nTDSSettingsDN; ADEntity[] domainController = aDTopologyManagement.GetDomainController(strArrays); if (domainController == null || (int)domainController.Length == 0) { DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetExtendedObjectFromIdentity: No objects returned from custom action", new object[0])); throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectNotFound, new object[0])); } else { AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(propertiesToFetch); T aDSessionInfo = this.Construct(domainController[0], attributeSetRequest); aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; t = aDSessionInfo; } } return(t); } else { DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetExtendedObjectFromIdentity: Could not find the DirectoryServer's NTDS Settings DN", new object[0])); object[] identity = new object[1]; identity[0] = identityObj.Identity; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.DirectoryServerNotFound, identity)); } }
internal override T Construct(ADEntity directoryObj, AttributeSetRequest requestedAttributes) { requestedAttributes = base.ConstructAttributeSetRequest(null); return(base.Construct(directoryObj, requestedAttributes)); }
protected bool ADGetPropertiesCmdletBaseProcessCSRoutine() { if (this._cmdletParameters.Contains("Identity")) { O item = (O)(this._cmdletParameters["Identity"] as O); this.SetPipelinedSessionInfo(item.SessionInfo); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); this._returnObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); if (this.IdentityLookupMode != IdentityLookupMode.DirectoryMode || this.SourcePropertyType != SourcePropertyType.LinkedDN) { if (this.IdentityLookupMode != IdentityLookupMode.FactoryMode || this.SourcePropertyType != SourcePropertyType.IdentityInfo) { if (this.IdentityLookupMode == IdentityLookupMode.DirectoryMode && this.SourcePropertyType == SourcePropertyType.IdentityInfo) { string identityObjectDN = this.GetIdentityObjectDN(); if (identityObjectDN != null) { ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, identityObjectDN, ADSearchScope.Base); using (aDObjectSearcher) { aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); aDObjectSearcher.Properties.Add(this.SourceProperty); ADObject aDObject = aDObjectSearcher.FindOne(); this.WritePropertiesToOutput(item, aDObject); } } } } else { string[] sourceProperty = new string[1]; sourceProperty[0] = this.SourceProperty; O extendedObjectFromIdentity = this._factory.GetExtendedObjectFromIdentity(item, cmdletSessionInfo.DefaultPartitionPath, sourceProperty); this.WritePropertiesToOutput(item, extendedObjectFromIdentity); } } else { string str = this.GetIdentityObjectDN(); if (str != null) { AttributeSetRequest attributeSetRequest = this._returnObjectFactory.ConstructAttributeSetRequest(null); ADObjectSearcher structuralObjectFilter = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base); using (structuralObjectFilter) { structuralObjectFilter.AttributeScopedQuery = this.SourceProperty; structuralObjectFilter.Filter = this._returnObjectFactory.StructuralObjectFilter; structuralObjectFilter.Properties.AddRange(attributeSetRequest.DirectoryAttributes); structuralObjectFilter.AutoRangeRetrieve = this.AutoRangeRetrieve; IEnumerable <ADObject> aDObjects = structuralObjectFilter.FindAll(); if (aDObjects != null) { foreach (ADObject aDObject1 in aDObjects) { if (aDObject1 == null) { continue; } RO rO = this._returnObjectFactory.Construct(aDObject1, attributeSetRequest); base.WriteObject(rO); } } } } } } return(true); }
internal IEnumerable <T> GetAllDomainControllers(ICollection <string> propertiesToFetch) { IEnumerable <T> ts; string defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext; ADSearchScope aDSearchScope = ADSearchScope.Subtree; IADOPathNode aDOPathNode = ADDomainControllerFactory <T> ._domainControllerComputerObjectFilter; ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, aDSearchScope); using (aDObjectSearcher) { aDObjectSearcher.Filter = aDOPathNode; aDObjectSearcher.Properties.AddRange(ADDomainControllerFactory <T> ._domainControllerDefaultAttributes); List <ADObject> aDObjects = new List <ADObject>(); foreach (ADObject aDObject in aDObjectSearcher.FindAll()) { aDObjects.Add(aDObject); } if (aDObjects.Count != 0) { List <string> strs = new List <string>(); foreach (ADObject aDObject1 in aDObjects) { string value = aDObject1["serverReferenceBL"].Value as string; if (value == null) { DebugLogger.LogInfo("ADDomainControllerFactory", string.Format("Could not find property: {0} for identity: {1}", "serverReferenceBL", aDObject1.DistinguishedName)); } else { strs.Add(string.Concat("CN=NTDS Settings,", value)); } } if (strs.Count <= 0) { ts = null; } else { using (ADTopologyManagement aDTopologyManagement = new ADTopologyManagement(base.CmdletSessionInfo.ADSessionInfo)) { ADEntity[] domainController = aDTopologyManagement.GetDomainController(strs.ToArray()); if (domainController == null || (int)domainController.Length == 0) { ts = new List <T>(); } else { List <T> ts1 = new List <T>(); AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(propertiesToFetch); ADEntity[] aDEntityArray = domainController; for (int i = 0; i < (int)aDEntityArray.Length; i++) { ADEntity aDEntity = aDEntityArray[i]; T aDSessionInfo = this.Construct(aDEntity, attributeSetRequest); aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; ts1.Add(aDSessionInfo); } ts = ts1; } } } } else { ts = new List <T>(); } } return(ts); }
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); }