Exemplo n.º 1
0
        private static void FixDistinguishedNameForADObjectIDs(ADObject adObject, string tenantDistinguishedName)
        {
            string[] stdIDs = new string[]
            {
                ADObjectSchema.Id.Name,
                ADObjectSchema.OrganizationalUnitRoot.Name,
                ADObjectSchema.ConfigurationUnit.Name
            };
            IEnumerable <PropertyDefinition> enumerable = adObject.Schema.AllProperties;

            enumerable = from propertyDefinition in enumerable
                         where propertyDefinition != null
                         select propertyDefinition;

            enumerable = from propertyDefinition in enumerable
                         where propertyDefinition.Type == typeof(ADObjectId)
                         select propertyDefinition;

            enumerable = from propertyDefinition in enumerable
                         where propertyDefinition is ProviderPropertyDefinition && !((ProviderPropertyDefinition)propertyDefinition).IsReadOnly
                         select propertyDefinition;

            enumerable = from propertyDefinition in enumerable
                         where !stdIDs.Contains(propertyDefinition.Name)
                         select propertyDefinition;

            foreach (PropertyDefinition propertyDefinition2 in enumerable)
            {
                ProviderPropertyDefinition providerPropertyDefinition = (ProviderPropertyDefinition)propertyDefinition2;
                object obj;
                if (adObject.TryGetValueWithoutDefault(providerPropertyDefinition, out obj) && obj != null)
                {
                    if (providerPropertyDefinition.IsMultivalued)
                    {
                        MultiValuedProperty <ADObjectId> multiValuedProperty = obj as MultiValuedProperty <ADObjectId>;
                        int num = 0;
                        while (multiValuedProperty != null)
                        {
                            if (num >= multiValuedProperty.Count)
                            {
                                break;
                            }
                            ADObjectId adObjectId = multiValuedProperty[num];
                            multiValuedProperty[num] = new ADObjectId(tenantDistinguishedName, Guid.Empty);
                            multiValuedProperty[num] = FfoDirectorySession.ReplaceTenantDistinguishedName(tenantDistinguishedName, adObjectId);
                            num++;
                        }
                    }
                    else
                    {
                        ADObjectId adobjectId = obj as ADObjectId;
                        if (adobjectId != null)
                        {
                            adObject[providerPropertyDefinition] = FfoDirectorySession.ReplaceTenantDistinguishedName(tenantDistinguishedName, adobjectId);
                        }
                    }
                }
            }
        }