Esempio n. 1
0
        private static bool SetAndValidateClaimSourceType(ADObject directoryObj, StringBuilder errorBuffer)
        {
            bool flag = false;

            if (!directoryObj.Contains("msDS-ClaimSource"))
            {
                if (directoryObj.Contains("msDS-ClaimAttributeSource"))
                {
                    directoryObj.SetValue("msDS-ClaimSourceType", "AD");
                }
            }
            else
            {
                if (!directoryObj.Contains("msDS-ClaimValueType"))
                {
                    directoryObj.Add("msDS-ClaimValueType", (long)6);
                }
                else
                {
                    long?value = (long?)(directoryObj["msDS-ClaimValueType"].Value as long?);
                    if (value.Value != (long)6)
                    {
                        flag = true;
                        errorBuffer.AppendLine(StringResources.CTSourceOIDValueTypeError);
                    }
                }
                directoryObj.SetValue("msDS-ClaimSourceType", "Certificate");
            }
            return(!flag);
        }
Esempio n. 2
0
        private static bool VerifyRestrictValues(ADObject directoryObj, StringBuilder errorBuffer, CmdletSessionInfo cmdletSessionInfo, ADFactory <T> .DirectoryOperation operation)
        {
            bool flag;
            bool value;
            bool value1;
            bool flag1 = false;

            if (directoryObj.ModifiedProperties.Contains("msDS-ClaimIsValueSpaceRestricted"))
            {
                flag = true;
            }
            else
            {
                flag = directoryObj.AddedProperties.Contains("msDS-ClaimIsValueSpaceRestricted");
            }
            bool flag2 = flag;

            if (!directoryObj.Contains("msDS-ClaimPossibleValues"))
            {
                value = false;
            }
            else
            {
                value = directoryObj["msDS-ClaimPossibleValues"].Value != null;
            }
            bool flag3 = value;

            if (!directoryObj.InternalProperties.Contains("SuggestedValues"))
            {
                value1 = false;
            }
            else
            {
                value1 = directoryObj.InternalProperties["SuggestedValues"].Value != null;
            }
            bool flag4 = value1;

            if (operation == ADFactory <T> .DirectoryOperation.Create && !directoryObj.Contains("msDS-ClaimIsValueSpaceRestricted"))
            {
                directoryObj.SetValue("msDS-ClaimIsValueSpaceRestricted", flag4);
            }
            if (operation == ADFactory <T> .DirectoryOperation.Update && !flag2)
            {
                if (!flag3)
                {
                    directoryObj.SetValue("msDS-ClaimIsValueSpaceRestricted", false);
                }
                if (flag4 && !flag3)
                {
                    directoryObj.SetValue("msDS-ClaimIsValueSpaceRestricted", true);
                }
            }
            if (!flag4 && !flag3 && directoryObj.Contains("msDS-ClaimIsValueSpaceRestricted") && (bool)directoryObj["msDS-ClaimIsValueSpaceRestricted"].Value)
            {
                flag1 = true;
                errorBuffer.AppendLine(StringResources.ClaimTypeRestrictValueError);
            }
            return(!flag1);
        }
Esempio n. 3
0
        private bool ADClaimTypePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            bool          classes       = true;
            StringBuilder stringBuilder = new StringBuilder();

            if (operation == ADFactory <T> .DirectoryOperation.Create || ADFactory <T> .DirectoryOperation.Update == operation)
            {
                bool switchParameterBooleanValue = parameters.GetSwitchParameterBooleanValue("SourceTransformPolicy");
                if (switchParameterBooleanValue)
                {
                    directoryObj.SetValue("msDS-ClaimSourceType", "TransformPolicy");
                    directoryObj.ForceRemove("msDS-ClaimAttributeSource");
                    directoryObj.ForceRemove("msDS-ClaimSource");
                }
                classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndAttributeExclusiveness(directoryObj, stringBuilder, operation);

                classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndPossibleValueExclusiveness(directoryObj, stringBuilder);

                classes = classes & ADClaimTypeFactory <T> .SetAndValidateClaimSourceType(directoryObj, stringBuilder);

                classes = classes & ADClaimTypeFactory <T> .VerifyRestrictValues(directoryObj, stringBuilder, base.CmdletSessionInfo, operation);

                if (directoryObj.Contains("msDS-ClaimValueType"))
                {
                    ADClaimValueType num = (ADClaimValueType)((long)Convert.ToInt32(directoryObj["msDS-ClaimValueType"].Value, CultureInfo.InvariantCulture));
                    classes = classes & ADCBACUtil.VerifyAndSetPossibleValues(directoryObj, num, stringBuilder);
                }
                classes = classes & ADClaimTypeFactory <T> .VerifyAppliesToClasses(directoryObj, stringBuilder, base.CmdletSessionInfo);

                if (classes)
                {
                    return(false);
                }
                else
                {
                    stringBuilder.AppendLine(StringResources.CTParameterValidationFailure);
                    throw new ADException(stringBuilder.ToString());
                }
            }
            else
            {
                return(false);
            }
        }