Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
        protected internal string ResolveIdentityToNTDSSettingsDN(T identityObj, ICollection <string> propertiesToFetch, bool checkForDCs, out ADObject computerObj, out ADObject serverObj, out ADObject ntdsDSAObj)
        {
            string str = null;
            string str1;

            computerObj = null;
            serverObj   = null;
            ntdsDSAObj  = null;
            HashSet <string> strs = new HashSet <string>(ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes, StringComparer.OrdinalIgnoreCase);

            if (propertiesToFetch != null)
            {
                strs.UnionWith(propertiesToFetch);
            }
            string[] strArrays = new string[strs.Count];
            strs.CopyTo(strArrays);
            string        configurationNamingContext = base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext;
            ADSearchScope aDSearchScope = ADSearchScope.Subtree;
            IADOPathNode  aDOPathNode   = this.BuildIdentityFilter(identityObj);

            IADOPathNode[] structuralObjectFilter = new IADOPathNode[2];
            structuralObjectFilter[0] = aDOPathNode;
            structuralObjectFilter[1] = this.StructuralObjectFilter;
            aDOPathNode = ADOPathUtil.CreateAndClause(structuralObjectFilter);
            ADObjectSearcher nullable = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, configurationNamingContext, aDSearchScope);

            using (nullable)
            {
                nullable.Filter = aDOPathNode;
                nullable.Properties.AddRange(strArrays);
                if (checkForDCs)
                {
                    nullable.SearchOption = new SearchOption?(SearchOption.PhantomRoot);
                    nullable.SearchRoot   = string.Empty;
                }
                List <ADObject> aDObjects = new List <ADObject>();
                foreach (ADObject aDObject in nullable.FindAll())
                {
                    aDObjects.Add(aDObject);
                }
                if (aDObjects.Count != 0)
                {
                    DirectoryServerUtil.CheckIfObjectsRefersToSingleDirectoryServer(base.CmdletSessionInfo.ADSessionInfo, aDObjects, checkForDCs, out str, out computerObj, out serverObj, out ntdsDSAObj);
                    if (str == null)
                    {
                        str1 = null;
                    }
                    else
                    {
                        str1 = string.Concat("CN=NTDS Settings,", str);
                    }
                }
                else
                {
                    DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("Could  not find identity using the following filter: {0}", aDOPathNode.GetLdapFilterString()));
                    str1 = null;
                }
            }
            return(str1);
        }
        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);
        }
Esempio n. 9
0
        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 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);
 }
Esempio n. 11
0
 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;
     }
 }
Esempio n. 12
0
 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");
     }
 }
        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 WriteObjectsInBatch(List <IADOPathNode> filterList)
        {
            IADOPathNode item;

            if (filterList.Count != 1)
            {
                item = ADOPathUtil.CreateOrClause(filterList.ToArray());
            }
            else
            {
                item = filterList[0];
            }
            int?nullable = null;
            IEnumerable <RO> extendedObjectFromFilter = this._returnObjectFactory.GetExtendedObjectFromFilter(item, this.GetCmdletSessionInfo().DefaultPartitionPath, ADSearchScope.Subtree, null, nullable, new int?(this._pageSize), false);
            int num = 0;

            if (extendedObjectFromFilter != null)
            {
                foreach (RO rO in extendedObjectFromFilter)
                {
                    base.WriteObject(rO);
                    num++;
                }
            }
        }
Esempio n. 15
0
 internal IADOPathNode AppendObjectClassFilter(IADOPathNode filter)
 {
     IADOPathNode[] structuralObjectFilter = new IADOPathNode[2];
     structuralObjectFilter[0] = filter;
     structuralObjectFilter[1] = this._factory.StructuralObjectFilter;
     return(ADOPathUtil.CreateAndClause(structuralObjectFilter));
 }
Esempio n. 16
0
 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);
     }
 }
Esempio n. 17
0
 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);
 }
Esempio n. 18
0
 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");
     }
 }
Esempio n. 19
0
        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;
        }
Esempio n. 20
0
 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);
 }
Esempio n. 21
0
        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));
            }
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        internal static IADOPathNode ToSearchFlagInInt(int bit, bool isInverted, string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo)
        {
            BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode;

            if (binaryADOPathNode != null)
            {
                IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode;
                if (rightNode != null)
                {
                    if (rightNode.DataObject is bool)
                    {
                        ADOperator @operator = binaryADOPathNode.Operator;
                        if (@operator == ADOperator.Eq || @operator == ADOperator.Ne)
                        {
                            IADOPathNode aDOPathNode = new BinaryADOPathNode(ADOperator.Bor, new PropertyADOPathNode(directoryAttributes[0]), new ObjectADOPathNode((object)bit));
                            bool         dataObject  = !(bool)rightNode.DataObject;
                            if (@operator == ADOperator.Ne)
                            {
                                dataObject = !dataObject;
                            }
                            if (isInverted)
                            {
                                dataObject = !dataObject;
                            }
                            if (dataObject)
                            {
                                aDOPathNode = ADOPathUtil.CreateNotClause(aDOPathNode);
                            }
                            return(aDOPathNode);
                        }
                        else
                        {
                            object[]     str             = new object[2];
                            ADOperator[] aDOperatorArray = new ADOperator[2];
                            aDOperatorArray[1] = ADOperator.Ne;
                            str[0]             = SearchConverters.ConvertOperatorListToString(aDOperatorArray);
                            str[1]             = extendedAttributeName;
                            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, str));
                        }
                    }
                    else
                    {
                        object[] type = new object[2];
                        type[0] = rightNode.DataObject.GetType();
                        type[1] = extendedAttributeName;
                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterRHSInvalidType, type));
                    }
                }
                else
                {
                    throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode);
                }
            }
            else
            {
                throw new ArgumentException(StringResources.SearchConverterNotBinaryNode);
            }
        }
Esempio n. 24
0
 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);
 }
Esempio n. 25
0
        public static IADOPathNode ToSearchGroupScope(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo)
        {
            ADGroupScope      aDGroupScope      = ADGroupScope.DomainLocal;
            BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode;

            if (binaryADOPathNode == null)
            {
                throw new ArgumentException(StringResources.SearchConverterNotBinaryNode);
            }
            else
            {
                if (binaryADOPathNode.Operator == ADOperator.Eq || binaryADOPathNode.Operator == ADOperator.Ne)
                {
                    IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode;
                    if (rightNode == null)
                    {
                        throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode);
                    }
                    else
                    {
                        if (!Utils.TryParseEnum <ADGroupScope>(rightNode.DataObject.ToString(), out aDGroupScope))
                        {
                            object[] str = new object[2];
                            str[0] = rightNode.DataObject.ToString();
                            str[1] = extendedAttributeName;
                            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterInvalidValue, str));
                        }
                        else
                        {
                            PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]);
                            ObjectADOPathNode   objectADOPathNode   = new ObjectADOPathNode((object)GroupTypeUtils.GetDirectoryGroupTypeValue(aDGroupScope));
                            IADOPathNode        aDOPathNode         = new BinaryADOPathNode(ADOperator.Band, propertyADOPathNode, objectADOPathNode);
                            if (binaryADOPathNode.Operator != ADOperator.Eq)
                            {
                                return(ADOPathUtil.CreateNotClause(aDOPathNode));
                            }
                            else
                            {
                                return(aDOPathNode);
                            }
                        }
                    }
                }
                else
                {
                    object[]     objArray        = new object[2];
                    ADOperator[] aDOperatorArray = new ADOperator[2];
                    aDOperatorArray[1] = ADOperator.Ne;
                    objArray[0]        = SearchConverters.ConvertOperatorListToString(aDOperatorArray);
                    objArray[1]        = extendedAttributeName;
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, objArray));
                }
            }
        }
        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 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);
        }
Esempio n. 28
0
        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);
            }
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
        {
            ADObject aDObject;
            ADDefaultDomainPasswordPolicy aDDefaultDomainPasswordPolicy = identityObj;

            if (aDDefaultDomainPasswordPolicy != null)
            {
                if (base.CmdletSessionInfo != null)
                {
                    AttributeSetRequest attributeSetRequest    = this.ConstructAttributeSetRequest(propertiesToFetch);
                    IADOPathNode[]      structuralObjectFilter = new IADOPathNode[2];
                    structuralObjectFilter[0] = this.StructuralObjectFilter;
                    structuralObjectFilter[1] = this.BuildIdentityFilter(identityObj);
                    IADOPathNode     aDOPathNode          = ADOPathUtil.CreateAndClause(structuralObjectFilter);
                    string           defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext;
                    ADSearchScope    aDSearchScope        = ADSearchScope.Base;
                    ADObjectSearcher aDObjectSearcher     = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, aDSearchScope, showDeleted);
                    using (aDObjectSearcher)
                    {
                        aDObjectSearcher.Filter = aDOPathNode;
                        aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                        DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1} scope: {2}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot, aDObjectSearcher.Scope));
                        aDObject = aDObjectSearcher.FindOne();
                        if (aDObject == null)
                        {
                            DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Identity not found", new object[0]));
                            object[] str = new object[2];
                            str[0] = identityObj.ToString();
                            str[1] = aDObjectSearcher.SearchRoot;
                            throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str));
                        }
                    }
                    T aDSessionInfo = this.Construct(aDObject, attributeSetRequest);
                    aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo;
                    return(aDSessionInfo);
                }
                else
                {
                    throw new ArgumentNullException(StringResources.SessionRequired);
                }
            }
            else
            {
                object[] type = new object[2];
                type[0] = "GetExtendedObjectFromIdentity";
                type[1] = identityObj.GetType();
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type));
            }
        }