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; } }
static ADReplicationSiteFactory() { ADReplicationSiteFactory <T> ._structuralObjectFilter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "site"); ADReplicationSiteFactory <T> ._rDNPrefix = "CN"; ADReplicationSiteFactory <T> ._structuralObjectClass = "site"; string[] strArrays = new string[1]; strArrays[0] = "name"; ADReplicationSiteFactory <T> ._identityLdapAttributes = strArrays; IdentityResolverDelegate[] customIdentityResolver = new IdentityResolverDelegate[2]; customIdentityResolver[0] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.DistinguishedNameIdentityResolver)); IdentityResolverDelegate[] genericIdentityResolver = new IdentityResolverDelegate[2]; genericIdentityResolver[0] = IdentityResolverMethods.GetGenericIdentityResolver(ADReplicationSiteFactory <T> ._identityLdapAttributes); genericIdentityResolver[1] = new IdentityResolverDelegate(IdentityResolverMethods.GuidSearchFilterIdentityResolver); customIdentityResolver[1] = IdentityResolverMethods.GetAggregatedIdentityResolver(ADOperator.Or, genericIdentityResolver); ADReplicationSiteFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[4]; attributeConverterEntry[0] = new AttributeConverterEntry("Name", "name", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[1] = new AttributeConverterEntry(ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.Description.PropertyName, ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.Description.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[2] = new AttributeConverterEntry(ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.Subnet.PropertyName, ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.Subnet.ADAttribute, TypeConstants.ADReplicationSubnet, true, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[3] = new AttributeConverterEntry(ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.ManagedBy.PropertyName, ADReplicationSiteFactory <T> .ADReplicationSitePropertyMap.ManagedBy.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(ADReplicationSiteFactory <T> .ToDirectoryFromNameToManagedByDN), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); ADReplicationSiteFactory <T> .ADMappingTable = attributeConverterEntry; ADReplicationSiteFactory <T> .ADAMMappingTable = ADReplicationSiteFactory <T> .ADMappingTable; ADFactoryBase <T> .RegisterMappingTable(ADReplicationSiteFactory <T> .ADMappingTable, ADServerType.ADDS); ADFactoryBase <T> .RegisterMappingTable(ADReplicationSiteFactory <T> .ADAMMappingTable, ADServerType.ADLDS); }
static ADObjectFactory() { ADObjectFactory <T> ._structuralObjectFilter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); ADObjectFactory <T> ._rDNPrefix = "CN"; ADObjectFactory <T> ._structuralObjectClass = "top"; ADObjectFactory <T> ._identityLdapAttributes = new string[0]; IdentityResolverDelegate[] customIdentityResolver = new IdentityResolverDelegate[2]; customIdentityResolver[0] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.DistinguishedNameIdentityResolver)); customIdentityResolver[1] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.GuidIdentityResolver)); ADObjectFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[14]; attributeConverterEntry[0] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.DistinguishedName.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.DistinguishedName.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[1] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.ObjectClass.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.ObjectClass.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.CanonicalName.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.CanonicalName.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.GUID.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.GUID.ADAttribute, TypeConstants.Guid, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchGuid)); attributeConverterEntry[4] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.CN.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.CN.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[5] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.CreationTimeStamp.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.CreationTimeStamp.ADAttribute, TypeConstants.DateTime, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedDateTimeFromDateTime), null, new ToSearchFilterDelegate(SearchConverters.ToSearchDateTimeUsingSchemaInfo)); attributeConverterEntry[6] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.Description.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.Description.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[7] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.DisplayName.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.DisplayName.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[8] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.IsDeleted.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.IsDeleted.ADAttribute, TypeConstants.Bool, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[9] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.LastKnownParent.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.LastKnownParent.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[10] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.ModifiedTimeStamp.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.ModifiedTimeStamp.ADAttribute, TypeConstants.DateTime, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedDateTimeFromDateTime), null, new ToSearchFilterDelegate(SearchConverters.ToSearchDateTimeUsingSchemaInfo)); attributeConverterEntry[11] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.ObjectCategory.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.ObjectCategory.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[12] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.Name.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.Name.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[13] = new AttributeConverterEntry(ADObjectFactory <T> .ADObjectPropertyMap.ProtectedFromDeletion.PropertyName, ADObjectFactory <T> .ADObjectPropertyMap.ProtectedFromDeletion.ADAttribute, TypeConstants.Bool, false, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(ADObjectFactory <T> .ToExtendedProtectedFromDeletion), null, new ToSearchFilterDelegate(SearchConverters.ToSearchNotSupported)); ADObjectFactory <T> .ADMappingTable = attributeConverterEntry; ADObjectFactory <T> .ADAMMappingTable = ADObjectFactory <T> .ADMappingTable; ADFactoryBase <T> .RegisterMappingTable(ADObjectFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADObjectFactory <T> .ADMappingTable, ADServerType.ADDS); }
static ADPrincipalFactory() { ADPrincipalFactory <T> ._principalStructuralFilter = null; string[] strArrays = new string[1]; strArrays[0] = "sAMAccountName"; ADPrincipalFactory <T> ._principalIdentityLdapAttributes = strArrays; IdentityResolverDelegate[] customIdentityResolver = new IdentityResolverDelegate[5]; customIdentityResolver[0] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.DistinguishedNameIdentityResolver)); customIdentityResolver[1] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.GuidIdentityResolver)); customIdentityResolver[2] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.SidIdentityResolver)); customIdentityResolver[3] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.SamAccountNameIdentityResolver)); customIdentityResolver[4] = IdentityResolverMethods.GetGenericIdentityResolver(ADPrincipalFactory <T> ._principalIdentityLdapAttributes); ADPrincipalFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[5]; attributeConverterEntry[0] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.SamAccountName.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.SamAccountName.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[1] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.SID.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.SID.ADAttribute, TypeConstants.SID, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.HomePage.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.HomePage.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.SIDHistory.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.SIDHistory.ADAttribute, TypeConstants.SID, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[4] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.MemberOf.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.MemberOf.ADAttribute, TypeConstants.ADGroup, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADPrincipalFactory <T> .ADMappingTable = attributeConverterEntry; AttributeConverterEntry[] attributeConverterEntryArray = new AttributeConverterEntry[3]; attributeConverterEntryArray[0] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.SID.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.SID.ADAMAttribute, TypeConstants.SID, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[1] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.HomePage.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.HomePage.ADAMAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[2] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.MemberOf.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.MemberOf.ADAMAttribute, TypeConstants.ADGroup, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADPrincipalFactory <T> .ADAMMappingTable = attributeConverterEntryArray; IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "group"); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "user"); ADPrincipalFactory <T> ._principalStructuralFilter = ADOPathUtil.CreateOrClause(aDOPathNodeArray); ADFactoryBase <T> .RegisterMappingTable(ADPrincipalFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADPrincipalFactory <T> .ADMappingTable, ADServerType.ADDS); }
internal virtual List <IADOPathNode> BuildIdentityFilterListFromString(string identity) { if (identity != null) { List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>((int)this.IdentityLdapAttributes.Length); string[] identityLdapAttributes = this.IdentityLdapAttributes; for (int i = 0; i < (int)identityLdapAttributes.Length; i++) { string str = identityLdapAttributes[i]; if (str != "distinguishedName") { aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, str, identity)); } else { string str1 = Utils.EscapeDNForFilter(identity); aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, str, str1)); } } return(aDOPathNodes); } else { throw new ArgumentNullException("identity"); } }
internal static ADObjectSearcher BuildSidBaseSearcher(SecurityIdentifier sidObject, string searchRoot, CmdletSessionInfo cmdletSessionInfo) { ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, searchRoot, ADSearchScope.Subtree); aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectSid", sidObject); return(aDObjectSearcher); }
internal static bool IsAttributeValueUsed <F, O>(string attributeName, string attributeValue, CmdletSessionInfo cmdletSessionInfo, string searchPath) where F : ADFactory <O>, new() where O : ADEntity, new() { bool flag; IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, attributeName, attributeValue); F f = Activator.CreateInstance <F>(); f.SetCmdletSessionInfo(cmdletSessionInfo); int? nullable = null; int? nullable1 = null; IEnumerable <O> extendedObjectFromFilter = f.GetExtendedObjectFromFilter(aDOPathNode, searchPath, ADSearchScope.Subtree, null, nullable, nullable1, false); IEnumerator <O> enumerator = extendedObjectFromFilter.GetEnumerator(); using (enumerator) { if (enumerator.MoveNext()) { //TODO: Review: enumerator.Current; flag = true; } else { return(false); } } return(flag); }
static ADFineGrainedPasswordPolicyFactory() { ADFineGrainedPasswordPolicyFactory <T> ._fgppStructuralFilter = null; string[] strArrays = new string[2]; strArrays[0] = "name"; strArrays[1] = "distinguishedName"; ADFineGrainedPasswordPolicyFactory <T> ._fgppIdentityLdapAttributes = strArrays; IdentityResolverDelegate[] aggregatedIdentityResolver = new IdentityResolverDelegate[1]; IdentityResolverDelegate[] genericIdentityResolver = new IdentityResolverDelegate[2]; genericIdentityResolver[0] = IdentityResolverMethods.GetGenericIdentityResolver(ADFineGrainedPasswordPolicyFactory <T> ._fgppIdentityLdapAttributes); genericIdentityResolver[1] = new IdentityResolverDelegate(IdentityResolverMethods.GuidSearchFilterIdentityResolver); aggregatedIdentityResolver[0] = IdentityResolverMethods.GetAggregatedIdentityResolver(ADOperator.Or, genericIdentityResolver); ADFineGrainedPasswordPolicyFactory <T> ._identityResolvers = aggregatedIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[11]; attributeConverterEntry[0] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutDuration.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutDuration.ADAttribute, TypeConstants.TimeSpan, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedNoExpirationTimeSpan), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryNegativeTimeSpan), new ToSearchFilterDelegate(SearchConverters.ToSearchNegativeTimeSpan)); attributeConverterEntry[1] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutObservationWindow.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutObservationWindow.ADAttribute, TypeConstants.TimeSpan, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedNoExpirationTimeSpan), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryNegativeTimeSpan), new ToSearchFilterDelegate(SearchConverters.ToSearchNegativeTimeSpan)); attributeConverterEntry[2] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutThreshold.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.LockoutThreshold.ADAttribute, TypeConstants.Int, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MaxPasswordAge.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MaxPasswordAge.ADAttribute, TypeConstants.TimeSpan, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedNoExpirationTimeSpan), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryNoExpirationTimeSpan), new ToSearchFilterDelegate(SearchConverters.ToSearchNegativeTimeSpan)); attributeConverterEntry[4] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MinPasswordAge.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MinPasswordAge.ADAttribute, TypeConstants.TimeSpan, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedNoExpirationTimeSpan), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryNegativeTimeSpan), new ToSearchFilterDelegate(SearchConverters.ToSearchNegativeTimeSpan)); attributeConverterEntry[5] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MinPasswordLength.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.MinPasswordLength.ADAttribute, TypeConstants.Int, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[6] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.PasswordHistoryCount.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.PasswordHistoryCount.ADAttribute, TypeConstants.Int, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[7] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.ComplexityEnabled.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.ComplexityEnabled.ADAttribute, TypeConstants.Bool, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[8] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.ReversibleEncryptionEnabled.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.ReversibleEncryptionEnabled.ADAttribute, TypeConstants.Bool, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[9] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.Precedence.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.Precedence.ADAttribute, TypeConstants.Int, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[10] = new AttributeConverterEntry(ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.AppliesTo.PropertyName, ADFineGrainedPasswordPolicyFactory <T> .ADFineGrainedPasswordPolicyPropertyMap.AppliesTo.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADFineGrainedPasswordPolicyFactory <T> .ADMappingTable = attributeConverterEntry; ADFineGrainedPasswordPolicyFactory <T> ._fgppStructuralFilter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "msDS-PasswordSettings"); ADFactoryBase <T> .RegisterMappingTable(ADFineGrainedPasswordPolicyFactory <T> .ADMappingTable, ADServerType.ADDS); }
static ADServiceAccountFactory() { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2]; aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "msDS-ManagedServiceAccount"); aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectCategory", "msDS-ManagedServiceAccount"); aDOPathNodeArray[0] = ADOPathUtil.CreateAndClause(aDOPathNodeArray1); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "msDS-GroupManagedServiceAccount"); ADServiceAccountFactory <T> ._structuralObjectFilter = ADOPathUtil.CreateOrClause(aDOPathNodeArray); string[] strArrays = new string[1]; strArrays[0] = "sAMAccountName"; ADServiceAccountFactory <T> ._serviceAccountIdentityLdapAttributes = strArrays; IdentityResolverDelegate[] customIdentityResolver = new IdentityResolverDelegate[5]; customIdentityResolver[0] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.DistinguishedNameIdentityResolver)); customIdentityResolver[1] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.GuidIdentityResolver)); customIdentityResolver[2] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.SidIdentityResolver)); customIdentityResolver[3] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.SamAccountNameIdentityResolver)); customIdentityResolver[4] = ADComputerUtil.GetGenericIdentityResolverWithSamName(ADServiceAccountFactory <T> ._serviceAccountIdentityLdapAttributes); ADServiceAccountFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[5]; attributeConverterEntry[0] = new AttributeConverterEntry(ADPrincipalFactory <T> .ADPrincipalPropertyMap.SamAccountName.PropertyName, ADPrincipalFactory <T> .ADPrincipalPropertyMap.SamAccountName.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(ADComputerUtil.ToDirectoryServiceAccountSamAccountName), new ToSearchFilterDelegate(ADComputerUtil.ToSearchComputerSamAccountName)); attributeConverterEntry[1] = new AttributeConverterEntry(ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.HostComputers.PropertyName, ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.HostComputers.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.DNSHostName.PropertyName, ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.DNSHostName.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.PrincipalsAllowedToRetrieveManagedPassword.PropertyName, ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.PrincipalsAllowedToRetrieveManagedPassword.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedPrincipalFromSecDesc), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectorySecDescFromPrincipal), new ToSearchFilterDelegate(SearchConverters.ToSearchNotSupported)); attributeConverterEntry[4] = new AttributeConverterEntry(ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.ManagedPasswordIntervalInDays.PropertyName, ADServiceAccountFactory <T> .ADServiceAccountPropertyMap.ManagedPasswordIntervalInDays.ADAttribute, TypeConstants.Int, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADServiceAccountFactory <T> .ADMappingTable = attributeConverterEntry; ADFactoryBase <T> .RegisterMappingTable(ADServiceAccountFactory <T> .ADMappingTable, ADServerType.ADDS); ADAccountFactory <T> .DefaultUserAccessControl = 0x1002; ADAccountFactory <T> .UseComputerPasswordGeneration = true; }
static ADDomainFactory() { ADDomainFactory <T> ._domainStructuralFilter = null; ADDomainFactory <T> ._domainIdentityLdapAttributes = null; ADDomainFactory <T> ._domainStructuralObjectClass = "domainDNS"; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[18]; attributeConverterEntry[0] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.AllowedDNSSuffixes.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.AllowedDNSSuffixes.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[1] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.LastLogonReplicationInterval.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.LastLogonReplicationInterval.ADAttribute, TypeConstants.TimeSpan, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryDaysFromTimeSpan), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.ManagedBy.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.ManagedBy.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>), new ToSearchFilterDelegate(SearchConverters.ToSearchFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>)); attributeConverterEntry[3] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.DomainMode.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.DomainMode.ADAttribute, TypeConstants.ADDomainMode, true, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObjectWithCast <int>), new ToSearchFilterDelegate(SearchConverters.ToSearchEnum <ADDomainMode>)); attributeConverterEntry[4] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.DomainSID.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.DomainSID.ADAttribute, TypeConstants.SID, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[5] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.LinkedGroupPolicyObjects.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.LinkedGroupPolicyObjects.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[6] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.ChildDomains.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.ChildDomains.ADAttribute, TypeConstants.ADDomain, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[7] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.ComputersContainer.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.ComputersContainer.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[8] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.DomainControllersContainer.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.DomainControllersContainer.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[9] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.ForeignSecurityPrincipalsContainer.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.ForeignSecurityPrincipalsContainer.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[10] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.Forest.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.Forest.ADAttribute, TypeConstants.ADForest, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[11] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.InfrastructureMaster.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.InfrastructureMaster.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[12] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.NetBIOSName.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.NetBIOSName.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[13] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.PDCEmulator.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.PDCEmulator.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[14] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.ParentDomain.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.ParentDomain.ADAttribute, TypeConstants.ADDomain, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[15] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.RIDMaster.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.RIDMaster.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[16] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.SystemsContainer.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.SystemsContainer.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[17] = new AttributeConverterEntry(ADDomainFactory <T> .ADDomainPropertyMap.UsersContainer.PropertyName, ADDomainFactory <T> .ADDomainPropertyMap.UsersContainer.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADDomainFactory <T> .ADMappingTable = attributeConverterEntry; ADDomainFactory <T> ._domainStructuralFilter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", ADDomainFactory <T> ._domainStructuralObjectClass); string[] strArrays = new string[3]; strArrays[0] = "distinguishedName"; strArrays[1] = "objectSid"; strArrays[2] = "objectGUID"; ADDomainFactory <T> ._domainIdentityLdapAttributes = strArrays; ADFactoryBase <T> .RegisterMappingTable(ADDomainFactory <T> .ADMappingTable, ADServerType.ADDS); }
static ADForestFactory() { ADForestFactory <T> ._forestStructuralFilter = null; ADForestFactory <T> ._forestIdentityLdapAttributes = null; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[13]; attributeConverterEntry[0] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.UPNSuffixes.PropertyName, ADForestFactory <T> .ADForestPropertyMap.UPNSuffixes.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[1] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.SPNSuffixes.PropertyName, ADForestFactory <T> .ADForestPropertyMap.SPNSuffixes.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[2] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.PartitionsContainer.PropertyName, ADForestFactory <T> .ADForestPropertyMap.PartitionsContainer.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObject)); attributeConverterEntry[3] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.ForestMode.PropertyName, ADForestFactory <T> .ADForestPropertyMap.ForestMode.ADAttribute, TypeConstants.ADForestMode, true, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObjectWithCast <int>), new ToSearchFilterDelegate(SearchConverters.ToSearchEnum <ADForestMode>)); attributeConverterEntry[4] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.ApplicationPartitions.PropertyName, ADForestFactory <T> .ADForestPropertyMap.ApplicationPartitions.ADAttribute, TypeConstants.ADPartition, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[5] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.CrossForestReferences.PropertyName, ADForestFactory <T> .ADForestPropertyMap.CrossForestReferences.ADAttribute, TypeConstants.ADPartition, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[6] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.Domains.PropertyName, ADForestFactory <T> .ADForestPropertyMap.Domains.ADAttribute, TypeConstants.ADDomain, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[7] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.GlobalCatalogs.PropertyName, ADForestFactory <T> .ADForestPropertyMap.GlobalCatalogs.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[8] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.Sites.PropertyName, ADForestFactory <T> .ADForestPropertyMap.Sites.ADAttribute, TypeConstants.ADReplicationSite, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchMultivalueObject)); attributeConverterEntry[9] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.DomainNamingMaster.PropertyName, ADForestFactory <T> .ADForestPropertyMap.DomainNamingMaster.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObject)); attributeConverterEntry[10] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.RootDomain.PropertyName, ADForestFactory <T> .ADForestPropertyMap.RootDomain.ADAttribute, TypeConstants.ADDomain, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObject)); attributeConverterEntry[11] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.Name.PropertyName, ADForestFactory <T> .ADForestPropertyMap.Name.ADAttribute, TypeConstants.ADDomain, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObject)); attributeConverterEntry[12] = new AttributeConverterEntry(ADForestFactory <T> .ADForestPropertyMap.SchemaMaster.PropertyName, ADForestFactory <T> .ADForestPropertyMap.SchemaMaster.ADAttribute, TypeConstants.ADDomainController, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObject)); ADForestFactory <T> .ADMappingTable = attributeConverterEntry; ADForestFactory <T> ._forestStructuralFilter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRefContainer"); string[] strArrays = new string[3]; strArrays[0] = "distinguishedName"; strArrays[1] = "objectSid"; strArrays[2] = "objectGUID"; ADForestFactory <T> ._forestIdentityLdapAttributes = strArrays; ADFactoryBase <T> .RegisterMappingTable(ADForestFactory <T> .ADMappingTable, ADServerType.ADDS); }
internal override IADOPathNode IdentitySearchConverter(object identity) { if (identity != null) { string str = identity as string; if (str != null) { string str1 = ADDomainUtil.FindDomainNCHead(str, base.CmdletSessionInfo); if (str1 != null) { return(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", str1)); } } SecurityIdentifier securityIdentifier = identity as SecurityIdentifier; if (securityIdentifier == null) { IADOPathNode aDOPathNode = base.IdentitySearchConverter(identity); return(aDOPathNode); } else { return(ADDomainUtil.CreateSidFilterClause(securityIdentifier)); } } else { throw new ArgumentNullException("Identity"); } }
private bool ADReplicationSiteRemovePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj) { if (ADFactory <T> .DirectoryOperation.Delete == operation) { ADObjectFactory <ADObject> aDObjectFactory = new ADObjectFactory <ADObject>(); aDObjectFactory.SetCmdletSessionInfo(base.CmdletSessionInfo); IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server"); int? nullable = null; int? nullable1 = null; IEnumerable <ADObject> extendedObjectFromFilter = aDObjectFactory.GetExtendedObjectFromFilter(aDOPathNode, directoryObj.DistinguishedName, ADSearchScope.Subtree, null, nullable, nullable1, false); IEnumerator <ADObject> enumerator = extendedObjectFromFilter.GetEnumerator(); using (enumerator) { if (enumerator.MoveNext()) { //TODO: Review: URGENT!! : enumerator.Current; object[] distinguishedName = new object[1]; distinguishedName[0] = directoryObj.DistinguishedName; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.ServerContainerNotEmpty, distinguishedName)); } } return(false); } else { return(false); } }
public static string FindDomainNCHead(string identity, CmdletSessionInfo session) { ADObject aDObject; using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(session.ADSessionInfo)) { aDObjectSearcher.SearchRoot = string.Concat("CN=Partitions,", session.ADRootDSE.ConfigurationNamingContext); aDObjectSearcher.Scope = ADSearchScope.OneLevel; IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectCategory", "crossRef"); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", 3); IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[3]; aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nCName", identity); aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nETBIOSName", identity); aDOPathNodeArray1[2] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "dnsRoot", identity); aDOPathNodeArray[2] = ADOPathUtil.CreateOrClause(aDOPathNodeArray1); aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray); aDObjectSearcher.Properties.Add("nCName"); aDObject = aDObjectSearcher.FindOne(); } if (aDObject != null) { return(aDObject.GetValue("nCName") as string); } else { return(null); } }
static ADOrganizationalUnitFactory() { ADOrganizationalUnitFactory <T> ._structuralObjectFilter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "organizationalUnit"); ADOrganizationalUnitFactory <T> ._rDNPrefix = "OU"; ADOrganizationalUnitFactory <T> ._structuralObjectClass = "organizationalUnit"; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[7]; attributeConverterEntry[0] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.ManagedBy.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.ManagedBy.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>), new ToSearchFilterDelegate(SearchConverters.ToSearchFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>)); attributeConverterEntry[1] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Street.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Street.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.PostalCode.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.PostalCode.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.City.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.City.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[4] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.State.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.State.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[5] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Country.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Country.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[6] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.LinkedGroupPolicyObjects.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.LinkedGroupPolicyObjects.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(GPLinkUtil.ToExtendedGPLink), null, new ToSearchFilterDelegate(GPLinkUtil.ToSearchGPLink)); ADOrganizationalUnitFactory <T> .ADMappingTable = attributeConverterEntry; AttributeConverterEntry[] attributeConverterEntryArray = new AttributeConverterEntry[6]; attributeConverterEntryArray[0] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.ManagedBy.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.ManagedBy.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>), new ToSearchFilterDelegate(SearchConverters.ToSearchFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>)); attributeConverterEntryArray[1] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Street.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Street.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[2] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.PostalCode.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.PostalCode.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[3] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.City.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.City.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[4] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.State.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.State.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntryArray[5] = new AttributeConverterEntry(ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Country.PropertyName, ADOrganizationalUnitFactory <T> .ADOrganizationalUnitPropertyMap.Country.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADOrganizationalUnitFactory <T> .ADAMMappingTable = attributeConverterEntryArray; ADFactoryBase <T> .RegisterMappingTable(ADOrganizationalUnitFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADOrganizationalUnitFactory <T> .ADMappingTable, ADServerType.ADDS); }
static ADDirectoryServerFactory() { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "nTDSDSA"); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server"); ADDirectoryServerFactory <T> ._directoryServerStructuralFilter = ADOPathUtil.CreateOrClause(aDOPathNodeArray); string[] strArrays = new string[6]; strArrays[0] = "name"; strArrays[1] = "distinguishedName"; strArrays[2] = "objectClass"; strArrays[3] = "objectGUID"; strArrays[4] = "dNSHostName"; strArrays[5] = "serverReferenceBL"; ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes = strArrays; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[14]; attributeConverterEntry[0] = new AttributeConverterEntry("Name", "Name", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[1] = new AttributeConverterEntry("Site", "Site", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[2] = new AttributeConverterEntry("IPv4Address", "HostName", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(ADComputerFactory <ADComputer> .ToExtendedIPv4), null, new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[3] = new AttributeConverterEntry("IPv6Address", "HostName", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(ADComputerFactory <ADComputer> .ToExtendedIPv6), null, new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[4] = new AttributeConverterEntry("Partitions", "Partitions", TypeConstants.String, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[5] = new AttributeConverterEntry("DefaultPartition", "DefaultPartition", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[6] = new AttributeConverterEntry("HostName", "HostName", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[7] = new AttributeConverterEntry("LdapPort", "LdapPort", TypeConstants.Int, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[8] = new AttributeConverterEntry("SslPort", "SslPort", TypeConstants.Int, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[9] = new AttributeConverterEntry("OperationMasterRoles", "OperationMasterRole", TypeConstants.ADOperationMasterRole, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[10] = new AttributeConverterEntry("NTDSSettingsObjectDN", "NTDSSettingsObjectDN", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[11] = new AttributeConverterEntry("ServerObjectDN", "ServerObjectDN", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[12] = new AttributeConverterEntry("ServerObjectGuid", "ServerObjectGuid", TypeConstants.Guid, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[13] = new AttributeConverterEntry("InvocationId", "InvocationId", TypeConstants.Guid, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); ADDirectoryServerFactory <T> .ADMappingTable = attributeConverterEntry; ADDirectoryServerFactory <T> .ADAMMappingTable = ADDirectoryServerFactory <T> .ADMappingTable; ADFactoryBase <T> .RegisterMappingTable(ADDirectoryServerFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADDirectoryServerFactory <T> .ADMappingTable, ADServerType.ADDS); }
static ADOptionalFeatureFactory() { ADOptionalFeatureFactory <T> ._ofStructuralFilter = null; string[] strArrays = new string[1]; strArrays[0] = "name"; ADOptionalFeatureFactory <T> ._ofIdentityLdapAttributes = strArrays; IdentityResolverDelegate[] customIdentityResolver = new IdentityResolverDelegate[3]; customIdentityResolver[0] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(IdentityResolverMethods.DistinguishedNameIdentityResolver)); customIdentityResolver[1] = IdentityResolverMethods.GetCustomIdentityResolver(new IdentityResolverDelegate(ADOptionalFeatureFactory <T> .ADOFGuidIdentityResolver)); customIdentityResolver[2] = IdentityResolverMethods.GetGenericIdentityResolver(ADOptionalFeatureFactory <T> ._ofIdentityLdapAttributes); ADOptionalFeatureFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[6]; attributeConverterEntry[0] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.EnabledScopes.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.EnabledScopes.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[1] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.FeatureScope.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.FeatureScope.ADAttribute, TypeConstants.Int, false, TypeAdapterAccess.Read, false, AttributeSet.Default, new ToExtendedFormatDelegate(ADOptionalFeatureFactory <T> .ToExtendedFeatureScope), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[2] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.IsDisableable.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.IsDisableable.ADAttribute, TypeConstants.Bool, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(ADOptionalFeatureFactory <T> .ToExtendedIsDisableable), null, new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.FeatureGUID.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.FeatureGUID.ADAttribute, TypeConstants.Guid, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedGuid), null, new ToSearchFilterDelegate(SearchConverters.ToSearchGuid)); attributeConverterEntry[4] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.RequiredDomainMode.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.RequiredDomainMode.ADAttribute, TypeConstants.ADDomainMode, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObjectWithCast <ADDomainMode>), null, new ToSearchFilterDelegate(SearchConverters.ToSearchEnum <ADDomainMode>)); attributeConverterEntry[5] = new AttributeConverterEntry(ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.RequiredForestMode.PropertyName, ADOptionalFeatureFactory <T> .ADOptionalFeaturePropertyMap.RequiredForestMode.ADAttribute, TypeConstants.ADForestMode, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObjectWithCast <ADForestMode>), null, new ToSearchFilterDelegate(SearchConverters.ToSearchEnum <ADForestMode>)); ADOptionalFeatureFactory <T> .ADMappingTable = attributeConverterEntry; ADOptionalFeatureFactory <T> .ADAMMappingTable = ADOptionalFeatureFactory <T> .ADMappingTable; ADOptionalFeatureFactory <T> ._ofStructuralFilter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "msDS-OptionalFeature"); ADFactoryBase <T> .RegisterMappingTable(ADOptionalFeatureFactory <T> .ADMappingTable, ADServerType.ADDS); ADFactoryBase <T> .RegisterMappingTable(ADOptionalFeatureFactory <T> .ADAMMappingTable, ADServerType.ADLDS); }
private void ValidateIdentity(T identityObj) { string str; if (identityObj != null) { if (base.CmdletSessionInfo != null) { if (!identityObj.IsSearchResult) { if (identityObj.Identity as ADDomain == null || !((ADDomain)identityObj.Identity).IsSearchResult) { str = identityObj.Identity.ToString(); } else { str = ((ADDomain)identityObj.Identity).DNSRoot; } } else { str = identityObj.Name; } ADRootDSE aDRootDSE = base.CmdletSessionInfo.ADRootDSE; string str1 = string.Concat("CN=Partitions,", aDRootDSE.ConfigurationNamingContext); ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str1, ADSearchScope.OneLevel); using (aDObjectSearcher) { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef"); IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2]; aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "dnsRoot", str); aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nETBIOSName", str); aDOPathNodeArray[1] = ADOPathUtil.CreateOrClause(aDOPathNodeArray1); aDOPathNodeArray[2] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", 3); aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray); ADObject aDObject = aDObjectSearcher.FindOne(); if (aDObject == null) { object[] objArray = new object[1]; objArray[0] = str; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.CouldNotFindForestIdentity, objArray)); } } return; } else { throw new ArgumentNullException(StringResources.SessionRequired); } } else { object[] type = new object[2]; type[0] = "ValidateIdentity"; type[1] = identityObj.GetType(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type)); } }
internal static ADObjectSearcher BuildObjectGuidSearcher(Guid?guidObject, string searchBase, CmdletSessionInfo cmdletSessionInfo) { ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, searchBase, ADSearchScope.Subtree); Guid value = guidObject.Value; aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectGUID", value.ToByteArray()); return(aDObjectSearcher); }
internal static List <IADOPathNode> BuildComputerSamAccountNameIdentityFilter(string identity, List <IADOPathNode> baseList) { if (!identity.EndsWith("$", StringComparison.OrdinalIgnoreCase)) { IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "sAMAccountName", string.Concat(identity, "$")); baseList.Add(aDOPathNode); } return(baseList); }
private static ADObjectSearcher BuildADOFGuidSearcher(Guid guidObject, string searchBase, CmdletSessionInfo cmdletSessionInfo) { ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, searchBase, ADSearchScope.Subtree); IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectGUID", guidObject.ToByteArray()); IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-OptionalFeatureGUID", guidObject.ToByteArray()); IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = aDOPathNode; aDOPathNodeArray[1] = aDOPathNode1; aDObjectSearcher.Filter = ADOPathUtil.CreateOrClause(aDOPathNodeArray); return(aDObjectSearcher); }
private double GetInactiveTimeSpanDays(CmdletSessionInfo cmdletSessionInfo) { double num = 0; double num1; ADRootDSE rootDSE = this.GetRootDSE(); string defaultNamingContext = rootDSE.DefaultNamingContext; if (rootDSE.ServerType != ADServerType.ADDS || defaultNamingContext == null) { return(15); } else { SearchADAccountCmdlet._accountInactiveTimeSpanLock.EnterReadLock(); try { if (!SearchADAccountCmdlet._accountInactiveTimeSpanCache.TryGetValue(defaultNamingContext, out num)) { double value = 15; ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, defaultNamingContext, ADSearchScope.Base); using (aDObjectSearcher) { aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); aDObjectSearcher.Properties.Add("msDS-LogonTimeSyncInterval"); ADObject aDObject = aDObjectSearcher.FindOne(); if (aDObject != null && aDObject.Contains("msDS-LogonTimeSyncInterval") && aDObject["msDS-LogonTimeSyncInterval"].Count > 0) { value = (double)((int)aDObject["msDS-LogonTimeSyncInterval"].Value); } } SearchADAccountCmdlet._accountInactiveTimeSpanLock.EnterWriteLock(); try { SearchADAccountCmdlet._accountInactiveTimeSpanCache[defaultNamingContext] = value; } finally { SearchADAccountCmdlet._accountInactiveTimeSpanLock.ExitWriteLock(); } return(value); } else { num1 = num; } } finally { SearchADAccountCmdlet._accountInactiveTimeSpanLock.ExitReadLock(); } return(num1); } }
internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted) { ADObject aDObject = null; ADObject aDObject1 = null; ADObject aDObject2 = null; ADObject aDSessionInfo; if (base.CmdletSessionInfo != null) { //base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext; string nTDSSettingsDN = this.ResolveIdentityToNTDSSettingsDN(identityObj, ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes, false, out aDObject, out aDObject1, out aDObject2); if (nTDSSettingsDN != null) { if (aDObject1 == null) { string str = nTDSSettingsDN.Substring("CN=NTDS Settings,".Length); ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base); using (aDObjectSearcher) { aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); aDObjectSearcher.Properties.AddRange(ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes); aDSessionInfo = aDObjectSearcher.FindOne(); if (aDSessionInfo == null) { DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0])); object[] objArray = new object[2]; objArray[0] = identityObj.ToString(); objArray[1] = str; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray)); } } } else { aDSessionInfo = aDObject1; } aDSessionInfo.TrackChanges = true; aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo; return(aDSessionInfo); } else { DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetDirectoryObjectFromIdentity: NTDS Settings DN for the given identity not found", new object[0])); object[] identity = new object[1]; identity[0] = identityObj.Identity; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.DirectoryServerNotFound, identity)); } } else { throw new ArgumentNullException(StringResources.SessionRequired); } }
private static int GetNTMixedDomainMode(CmdletSessionInfo cmdletSessionInfo) { int value; ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, cmdletSessionInfo.ADRootDSE.DefaultNamingContext, ADSearchScope.Base); using (aDObjectSearcher) { aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); aDObjectSearcher.Properties.Add("ntMixedDomain"); ADObject aDObject = aDObjectSearcher.FindOne(); value = (int)aDObject["ntMixedDomain"].Value; } return(value); }
static ADGroupFactory() { ADGroupFactory <T> ._groupStructuralFilter = null; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[4]; attributeConverterEntry[0] = new AttributeConverterEntry(ADGroupFactory <T> .ADGroupPropertyMap.GroupScope.PropertyName, ADGroupFactory <T> .ADGroupPropertyMap.GroupScope.ADAttribute, TypeConstants.ADGroupScope, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(GroupTypeUtils.ToExtendedGroupScope), new ToDirectoryFormatDelegate(GroupTypeUtils.ToDirectoryGroupScope), new ToSearchFilterDelegate(GroupTypeUtils.ToSearchGroupScope)); attributeConverterEntry[1] = new AttributeConverterEntry(ADGroupFactory <T> .ADGroupPropertyMap.GroupCategory.PropertyName, ADGroupFactory <T> .ADGroupPropertyMap.GroupCategory.ADAttribute, TypeConstants.ADGroupCategory, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Default, new ToExtendedFormatDelegate(GroupTypeUtils.ToExtendedGroupCategory), new ToDirectoryFormatDelegate(GroupTypeUtils.ToDirectoryGroupCategory), new ToSearchFilterDelegate(GroupTypeUtils.ToSearchGroupCategory)); attributeConverterEntry[2] = new AttributeConverterEntry(ADGroupFactory <T> .ADGroupPropertyMap.ManagedBy.PropertyName, ADGroupFactory <T> .ADGroupPropertyMap.ManagedBy.ADAttribute, TypeConstants.ADPrincipal, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>), new ToSearchFilterDelegate(SearchConverters.ToSearchFromADObjectToDN <ADPrincipalFactory <ADPrincipal>, ADPrincipal>)); attributeConverterEntry[3] = new AttributeConverterEntry(ADGroupFactory <T> .ADGroupPropertyMap.Members.PropertyName, ADGroupFactory <T> .ADGroupPropertyMap.Members.ADAttribute, TypeConstants.ADPrincipal, false, TypeAdapterAccess.Read, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADGroupFactory <T> .ADMappingTable = attributeConverterEntry; ADGroupFactory <T> .ADAMMappingTable = ADGroupFactory <T> .ADMappingTable; ADGroupFactory <T> ._groupStructuralFilter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "group"); ADFactoryBase <T> .RegisterMappingTable(ADGroupFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADGroupFactory <T> .ADMappingTable, ADServerType.ADDS); }
internal override IADOPathNode IdentitySearchConverter(object identity) { if (identity != null) { if ((int)this.IdentityLdapAttributes.Length <= 0) { return(null); } else { SecurityIdentifier securityIdentifier = identity as SecurityIdentifier; if (securityIdentifier == null) { IADOPathNode aDOPathNode = base.IdentitySearchConverter(identity); ADPrincipal aDPrincipal = identity as ADPrincipal; if (aDPrincipal == null) { return(aDOPathNode); } else { List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>(); if (aDPrincipal.SamAccountName != null) { aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "sAMAccountName", aDPrincipal.SamAccountName)); } if (aDPrincipal.SID != null) { aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectSid", aDPrincipal.SID)); } aDOPathNodes.Add(aDOPathNode); return(ADOPathUtil.CreateAndClause(aDOPathNodes.ToArray())); } } else { byte[] numArray = new byte[securityIdentifier.BinaryLength]; securityIdentifier.GetBinaryForm(numArray, 0); return(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectSid", numArray)); } } } else { throw new ArgumentNullException("identity"); } }
private void AddSessionFromSiteDN(string siteDN) { IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server"); List <string> strs = new List <string>(); strs.Add("dNSHostName"); ICollection <string> strs1 = strs; this._sharedADOFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo()); int?nullable = null; int?nullable1 = null; IEnumerable <ADObject> extendedObjectFromFilter = this._sharedADOFactory.GetExtendedObjectFromFilter(aDOPathNode, string.Concat("CN=Servers,", siteDN), ADSearchScope.OneLevel, strs1, nullable, nullable1, false); foreach (ADObject aDObject in extendedObjectFromFilter) { this._sessionPipe.AddLast(new ADSessionInfo(aDObject["dNSHostName"].Value as string)); } }
private void AddSessionsFromConnectedForest() { IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server"); List <string> strs = new List <string>(); strs.Add("dNSHostName"); ICollection <string> strs1 = strs; this._sharedADOFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo()); int?nullable = null; int?nullable1 = null; IEnumerable <ADObject> extendedObjectFromFilter = this._sharedADOFactory.GetExtendedObjectFromFilter(aDOPathNode, string.Concat("CN=Sites,", this.GetCmdletSessionInfo().ADRootDSE.ConfigurationNamingContext), ADSearchScope.Subtree, strs1, nullable, nullable1, false); foreach (ADObject aDObject in extendedObjectFromFilter) { this._sessionPipe.AddLast(new ADSessionInfo(aDObject["dNSHostName"].Value as string)); } }
static ADDomainControllerFactory() { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "computer"); IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2]; aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "primaryGroupID", "516"); aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "primaryGroupID", "521"); aDOPathNodeArray[1] = ADOPathUtil.CreateOrClause(aDOPathNodeArray1); ADDomainControllerFactory <T> ._domainControllerComputerObjectFilter = ADOPathUtil.CreateAndClause(aDOPathNodeArray); string[] strArrays = new string[7]; strArrays[0] = "name"; strArrays[1] = "distinguishedName"; strArrays[2] = "objectClass"; strArrays[3] = "objectGUID"; strArrays[4] = "dNSHostName"; strArrays[5] = "serverReference"; strArrays[6] = "serverReferenceBL"; ADDomainControllerFactory <T> ._domainControllerDefaultAttributes = strArrays; IADOPathNode[] aDOPathNodeArray2 = new IADOPathNode[3]; aDOPathNodeArray2[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "nTDSDSA"); aDOPathNodeArray2[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server"); aDOPathNodeArray2[2] = ADDomainControllerFactory <T> ._domainControllerComputerObjectFilter; ADDomainControllerFactory <T> ._domainControllerStructuralFilter = ADOPathUtil.CreateOrClause(aDOPathNodeArray2); string[] strArrays1 = new string[5]; strArrays1[0] = "distinguishedName"; strArrays1[1] = "objectGUID"; strArrays1[2] = "dNSHostName"; strArrays1[3] = "objectSid"; strArrays1[4] = "sAMAccountName"; ADDomainControllerFactory <T> ._identityLdapAttributes = strArrays1; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[10]; attributeConverterEntry[0] = new AttributeConverterEntry("IsReadOnly", "IsReadOnly", TypeConstants.Bool, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[1] = new AttributeConverterEntry("IsGlobalCatalog", "IsGlobalCatalog", TypeConstants.Bool, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[2] = new AttributeConverterEntry("Enabled", "Enabled", TypeConstants.Bool, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[3] = new AttributeConverterEntry("OperatingSystemVersion", "OSVersion", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[4] = new AttributeConverterEntry("OperatingSystem", "OSName", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[5] = new AttributeConverterEntry("OperatingSystemServicePack", "OSServicepack", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[6] = new AttributeConverterEntry("OperatingSystemHotfix", "OSHotFix", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[7] = new AttributeConverterEntry("ComputerObjectDN", "ComputerDN", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[8] = new AttributeConverterEntry("Domain", "Domain", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); attributeConverterEntry[9] = new AttributeConverterEntry("Forest", "Forest", TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Default, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchObjectClientSideFilter)); ADDomainControllerFactory <T> .ADMappingTable = attributeConverterEntry; ADFactoryBase <T> .RegisterMappingTable(ADDomainControllerFactory <T> .ADMappingTable, ADServerType.ADDS); }
private bool MoveADDirectoryServerProcessCSRoutine() { this._identityDSObj = this._cmdletParameters["Identity"] as ADDirectoryServer; base.SetPipelinedSessionInfo(this._identityDSObj.SessionInfo); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); ADDirectoryServerFactory <ADDirectoryServer> aDDirectoryServerFactory = new ADDirectoryServerFactory <ADDirectoryServer>(); aDDirectoryServerFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADObject directoryObjectFromIdentity = aDDirectoryServerFactory.GetDirectoryObjectFromIdentity(this._identityDSObj, cmdletSessionInfo.DefaultPartitionPath); string str = string.Concat("CN=Servers,", this._siteDirObj.DistinguishedName); ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base); using (aDObjectSearcher) { aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); ADObject aDObject = aDObjectSearcher.FindOne(); if (aDObject == null) { base.ThrowTerminatingError(ADUtilities.GetErrorRecord(new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectNotFound, new object[0])), "MoveADDirectoryServer:ProcessRecord", str)); } StringBuilder stringBuilder = new StringBuilder("Move-ADObject -identity $args[0] -Partition $args[1] -TargetPath $args[2] "); try { object[] configurationNamingContext = new object[3]; configurationNamingContext[0] = directoryObjectFromIdentity; configurationNamingContext[1] = cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext; configurationNamingContext[2] = aDObject.DistinguishedName; base.InvokeCommand.InvokeScript(stringBuilder.ToString(), false, PipelineResultTypes.Output, null, configurationNamingContext); } catch (RuntimeException runtimeException1) { RuntimeException runtimeException = runtimeException1; object[] distinguishedName = new object[3]; distinguishedName[0] = directoryObjectFromIdentity.DistinguishedName; distinguishedName[1] = this._siteDirObj.DistinguishedName; distinguishedName[2] = runtimeException.Message; string str1 = string.Format(CultureInfo.CurrentCulture, "Failed moving the directory server: {0} to new site: {1}. Error: {2}", distinguishedName); DebugLogger.LogError("MoveADDirectoryServer", str1); base.WriteError(new ErrorRecord(runtimeException, "0", ErrorCategory.WriteError, this._identityDSObj)); } } return(true); }