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 ADComputerFactory() { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "computer"); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectCategory", "computer"); ADComputerFactory <T> ._structuralObjectFilter = ADOPathUtil.CreateAndClause(aDOPathNodeArray); ADComputerFactory <T> ._rDNPrefix = "CN"; ADComputerFactory <T> ._structuralObjectClass = "computer"; string[] strArrays = new string[1]; strArrays[0] = "sAMAccountName"; ADComputerFactory <T> ._computerIdentityLdapAttributes = 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(ADComputerFactory <T> ._computerIdentityLdapAttributes); ADComputerFactory <T> ._identityResolvers = customIdentityResolver; AttributeConverterEntry[] attributeConverterEntry = new AttributeConverterEntry[11]; 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.ToDirectoryComputerSamAccountName), new ToSearchFilterDelegate(ADComputerUtil.ToSearchComputerSamAccountName)); attributeConverterEntry[1] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.DNSHostName.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.DNSHostName.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(ADComputerFactory <T> .ADComputerPropertyMap.ServiceAccount.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.ServiceAccount.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, false, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedMultivalueObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryMultivalueObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[3] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.IPv4Address.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.IPv4Address.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(ADComputerFactory <T> .ToExtendedIPv4), null, new ToSearchFilterDelegate(ADComputerFactory <T> .ToSearchIPv4)); attributeConverterEntry[4] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.IPv6Address.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.IPv6Address.ADAttribute, TypeConstants.String, false, TypeAdapterAccess.Read, true, AttributeSet.Extended, new ToExtendedFormatDelegate(ADComputerFactory <T> .ToExtendedIPv6), null, new ToSearchFilterDelegate(ADComputerFactory <T> .ToSearchIPv6)); attributeConverterEntry[5] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.Location.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.Location.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[6] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.ManagedBy.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.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[7] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.OS.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.OS.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(ADComputerFactory <T> .ADComputerPropertyMap.OSHotfix.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.OSHotfix.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[9] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.OSServicePack.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.OSServicePack.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); attributeConverterEntry[10] = new AttributeConverterEntry(ADComputerFactory <T> .ADComputerPropertyMap.OSVersion.PropertyName, ADComputerFactory <T> .ADComputerPropertyMap.OSVersion.ADAttribute, TypeConstants.String, true, TypeAdapterAccess.ReadWrite, true, AttributeSet.Extended, new ToExtendedFormatDelegate(AttributeConverters.ToExtendedObject), new ToDirectoryFormatDelegate(AttributeConverters.ToDirectoryObject), new ToSearchFilterDelegate(SearchConverters.ToSearchUsingSchemaInfo)); ADComputerFactory <T> .ADMappingTable = attributeConverterEntry; ADComputerFactory <T> .ADAMMappingTable = ADComputerFactory <T> .ADMappingTable; ADFactoryBase <T> .RegisterMappingTable(ADComputerFactory <T> .ADAMMappingTable, ADServerType.ADLDS); ADFactoryBase <T> .RegisterMappingTable(ADComputerFactory <T> .ADMappingTable, ADServerType.ADDS); ADAccountFactory <T> .DefaultUserAccessControl = 0x1002; ADAccountFactory <T> .UseComputerPasswordGeneration = true; }