protected static object GetPropertyBasedOnDefinition(PropertyDefinition definition, object propertyValue) { if (!(propertyValue is PSObject) || !(((PSObject)propertyValue).BaseObject is IList)) { return(MockObjectCreator.GetSingleProperty(propertyValue, definition.Type)); } IList list = ((PSObject)propertyValue).BaseObject as IList; if (definition.Type == typeof(ScheduleInterval[])) { List <ScheduleInterval> list2 = new List <ScheduleInterval>(); foreach (object prop in list) { list2.Add((ScheduleInterval)MockObjectCreator.GetSingleProperty(prop, typeof(ScheduleInterval))); } return(list2.ToArray()); } MultiValuedPropertyBase multiValuedPropertyBase = null; if (definition.Type == typeof(ProxyAddress)) { multiValuedPropertyBase = new ProxyAddressCollection(); } else if (definition.Type == typeof(ApprovedApplicationCollection)) { multiValuedPropertyBase = new ApprovedApplicationCollection(); } else { if (definition.Type.FullName == "Microsoft.Exchange.Management.RecipientTasks.MailboxRights[]") { if (MockObjectCreator.mailboxRightsEnum == null) { string assemblyFile = Path.Combine(ConfigurationContext.Setup.BinPath, "Microsoft.Exchange.Management.Recipient.dll"); MockObjectCreator.mailboxRightsEnum = Assembly.LoadFrom(assemblyFile).GetType("Microsoft.Exchange.Management.RecipientTasks.MailboxRights"); } Array array = Array.CreateInstance(MockObjectCreator.mailboxRightsEnum, list.Count); int num = 0; foreach (object prop2 in list) { array.SetValue(MockObjectCreator.GetSingleProperty(prop2, MockObjectCreator.mailboxRightsEnum), num); num++; } return(array); } multiValuedPropertyBase = new MultiValuedProperty <object>(); } foreach (object prop3 in list) { multiValuedPropertyBase.Add(MockObjectCreator.GetSingleProperty(prop3, definition.Type)); } return(multiValuedPropertyBase); }
protected override void FillProperty(Type type, PSObject psObject, ConfigurableObject configObject, string propertyName) { if (propertyName == "ApprovedApplicationList") { ApprovedApplicationCollection approvedApplicationCollection = new ApprovedApplicationCollection(); IList list = ((PSObject)psObject.Members[propertyName].Value).BaseObject as IList; foreach (object prop in list) { approvedApplicationCollection.Add(MockObjectCreator.GetSingleProperty(prop, typeof(ApprovedApplication))); } configObject.propertyBag[MobileMailboxPolicySchema.ADApprovedApplicationList] = approvedApplicationCollection; return; } base.FillProperty(type, psObject, configObject, propertyName); }
private static bool BuildEAS121Provisions(StringBuilder xml, int deviceVersion, IPolicyData mailboxPolicy) { bool flag = true; bool allowNonProvisionableDevices = mailboxPolicy.AllowNonProvisionableDevices; flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowStorageCard", mailboxPolicy.AllowStorageCard, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowCamera", mailboxPolicy.AllowCamera, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireDeviceEncryption", mailboxPolicy.RequireDeviceEncryption, allowNonProvisionableDevices, deviceVersion, 121, false); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowUnsignedApplications", mailboxPolicy.AllowUnsignedApplications, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowUnsignedInstallationPackages", mailboxPolicy.AllowUnsignedInstallationPackages, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= (ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MinDevicePasswordComplexCharacters", mailboxPolicy.MinDevicePasswordComplexCharacters, allowNonProvisionableDevices, deviceVersion, 121, 1) || !mailboxPolicy.AlphanumericDevicePasswordRequired); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowWiFi", mailboxPolicy.AllowWiFi, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowTextMessaging", mailboxPolicy.AllowTextMessaging, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowPOPIMAPEmail", mailboxPolicy.AllowPOPIMAPEmail, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowBluetooth", (int)mailboxPolicy.AllowBluetooth, allowNonProvisionableDevices, deviceVersion, 121, 2); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowIrDA", mailboxPolicy.AllowIrDA, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireManualSyncWhenRoaming", mailboxPolicy.RequireManualSyncWhenRoaming, allowNonProvisionableDevices, deviceVersion, 121, false); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowDesktopSync", mailboxPolicy.AllowDesktopSync, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxCalendarAgeFilter", (int)mailboxPolicy.MaxCalendarAgeFilter, allowNonProvisionableDevices, deviceVersion, 121, 0); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowHTMLEmail", mailboxPolicy.AllowHTMLEmail, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxEmailAgeFilter", (int)mailboxPolicy.MaxEmailAgeFilter, allowNonProvisionableDevices, deviceVersion, 121, 0); if (!mailboxPolicy.MaxEmailBodyTruncationSize.IsUnlimited) { flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxEmailBodyTruncationSize", mailboxPolicy.MaxEmailBodyTruncationSize.Value, allowNonProvisionableDevices, deviceVersion, 121, null); } else { flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxEmailBodyTruncationSize", -1, allowNonProvisionableDevices, deviceVersion, 121, -1); } if (!mailboxPolicy.MaxEmailHTMLBodyTruncationSize.IsUnlimited) { flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxEmailHTMLBodyTruncationSize", mailboxPolicy.MaxEmailHTMLBodyTruncationSize.Value, allowNonProvisionableDevices, deviceVersion, 121, null); } else { flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "MaxEmailHTMLBodyTruncationSize", -1, allowNonProvisionableDevices, deviceVersion, 121, -1); } flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireSignedSMIMEMessages", mailboxPolicy.RequireSignedSMIMEMessages, allowNonProvisionableDevices, deviceVersion, 121, false); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireEncryptedSMIMEMessages", mailboxPolicy.RequireEncryptedSMIMEMessages, allowNonProvisionableDevices, deviceVersion, 121, false); ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireSignedSMIMEAlgorithm", (int)mailboxPolicy.RequireSignedSMIMEAlgorithm, allowNonProvisionableDevices, deviceVersion, 121, false); ProvisionCommandPhaseOne.AppendEASAttribute(xml, "RequireEncryptionSMIMEAlgorithm", (int)mailboxPolicy.RequireEncryptionSMIMEAlgorithm, allowNonProvisionableDevices, deviceVersion, 121, false); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowSMIMEEncryptionAlgorithmNegotiation", (int)mailboxPolicy.AllowSMIMEEncryptionAlgorithmNegotiation, allowNonProvisionableDevices, deviceVersion, 121, 2); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowSMIMESoftCerts", mailboxPolicy.AllowSMIMESoftCerts, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowBrowser", mailboxPolicy.AllowBrowser, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowConsumerEmail", mailboxPolicy.AllowConsumerEmail, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowRemoteDesktop", mailboxPolicy.AllowRemoteDesktop, allowNonProvisionableDevices, deviceVersion, 121, true); flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "AllowInternetSharing", mailboxPolicy.AllowInternetSharing, allowNonProvisionableDevices, deviceVersion, 121, true); StringBuilder stringBuilder = new StringBuilder(300); MultiValuedProperty <string> unapprovedInROMApplicationList = mailboxPolicy.UnapprovedInROMApplicationList; if (unapprovedInROMApplicationList != null) { foreach (string str in unapprovedInROMApplicationList) { stringBuilder.AppendFormat("<{0}>{1}</{0}>", "ApplicationName", SecurityElement.Escape(str)); } } flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "UnapprovedInROMApplicationList", stringBuilder.ToString(), allowNonProvisionableDevices, deviceVersion, 121, string.Empty); stringBuilder.Length = 0; ApprovedApplicationCollection approvedApplicationList = mailboxPolicy.ApprovedApplicationList; if (approvedApplicationList != null) { foreach (ApprovedApplication approvedApplication in approvedApplicationList) { stringBuilder.AppendFormat("<{0}>{1}</{0}>", "Hash", Convert.ToBase64String(HexStringConverter.GetBytes(approvedApplication.AppHash, false))); } } flag &= ProvisionCommandPhaseOne.AppendEASAttribute(xml, "ApprovedApplicationList", stringBuilder.ToString(), allowNonProvisionableDevices, deviceVersion, 121, string.Empty); return(flag); }