ApplyAsync() public method

public ApplyAsync ( ) : IAsyncOperation
return IAsyncOperation
        private async void Launch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                
                EasClientSecurityPolicy RequestedPolicy = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientSecurityPolicy();

                CheckBox RequireEncryptionValue = rootPage.FindName("RequireEncryptionValue") as CheckBox;
                if (RequireEncryptionValue == null)
                    RequestedPolicy.RequireEncryption = false;
                else
                {
                    if (RequireEncryptionValue.IsChecked == true)
                        RequestedPolicy.RequireEncryption = true;
                    else
                        RequestedPolicy.RequireEncryption = false;
                }

                TextBox MinPasswordLengthValue = rootPage.FindName("MinPasswordLengthValue") as TextBox;
                if (MinPasswordLengthValue == null || MinPasswordLengthValue.Text.Length == 0)
                    RequestedPolicy.MinPasswordLength = 0;
                else
                {
                    RequestedPolicy.MinPasswordLength = Convert.ToByte(MinPasswordLengthValue.Text);
                }

                CheckBox DisallowConvenienceLogonValue = rootPage.FindName("DisallowConvenienceLogonValue") as CheckBox;
                if (DisallowConvenienceLogonValue == null)
                    RequestedPolicy.DisallowConvenienceLogon = false;
                else
                {
                    if (DisallowConvenienceLogonValue.IsChecked == true)
                        RequestedPolicy.DisallowConvenienceLogon = true;
                    else
                        RequestedPolicy.DisallowConvenienceLogon = false;
                }

                TextBox MinPasswordComplexCharactersValue = rootPage.FindName("MinPasswordComplexCharactersValue") as TextBox;
                if (MinPasswordComplexCharactersValue == null || MinPasswordComplexCharactersValue.Text.Length == 0)
                    RequestedPolicy.MinPasswordComplexCharacters = 0;
                else
                {
                    RequestedPolicy.MinPasswordComplexCharacters = Convert.ToByte(MinPasswordComplexCharactersValue.Text);
                }

                TextBox PasswordExpirationValue = rootPage.FindName("PasswordExpirationValue") as TextBox;
                if (PasswordExpirationValue == null || PasswordExpirationValue.Text.Length == 0)
                    RequestedPolicy.PasswordExpiration = TimeSpan.Parse("0");
                else
                {
                    RequestedPolicy.PasswordExpiration = TimeSpan.FromDays(Convert.ToDouble(PasswordExpirationValue.Text));
                }

                TextBox PasswordHistoryValue = rootPage.FindName("PasswordHistoryValue") as TextBox;
                if (PasswordHistoryValue == null || PasswordHistoryValue.Text.Length == 0)
                    RequestedPolicy.PasswordHistory = 0;
                else
                {
                    RequestedPolicy.PasswordHistory = Convert.ToByte(PasswordHistoryValue.Text);
                }

                TextBox MaxPasswordFailedAttemptsValue = rootPage.FindName("MaxPasswordFailedAttemptsValue") as TextBox;
                if (MaxPasswordFailedAttemptsValue == null || MaxPasswordFailedAttemptsValue.Text.Length == 0)
                    RequestedPolicy.MaxPasswordFailedAttempts = 0;
                else
                {
                    RequestedPolicy.MaxPasswordFailedAttempts = Convert.ToByte(MaxPasswordFailedAttemptsValue.Text);
                }

                TextBox MaxInactivityTimeLockValue = rootPage.FindName("MaxInactivityTimeLockValue") as TextBox;
                if (MaxInactivityTimeLockValue == null || MaxInactivityTimeLockValue.Text.Length == 0)
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.Parse("0");
                else
                {
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.FromSeconds(Convert.ToDouble(MaxInactivityTimeLockValue.Text));
                }

                Windows.Security.ExchangeActiveSyncProvisioning.EasComplianceResults ApplyResult = await RequestedPolicy.ApplyAsync();



                TextBox RequireEncryptionResult = rootPage.FindName("RequireEncryptionResult") as TextBox;
                RequireEncryptionResult.Text = ApplyResult.RequireEncryptionResult.ToString();

                TextBox MinPasswordLengthResult = rootPage.FindName("MinPasswordLengthResult") as TextBox;
                MinPasswordLengthResult.Text = ApplyResult.MinPasswordLengthResult.ToString();

                TextBox DisallowConvenienceLogonResult = rootPage.FindName("DisallowConvenienceLogonResult") as TextBox;
                DisallowConvenienceLogonResult.Text = ApplyResult.DisallowConvenienceLogonResult.ToString();

                TextBox MinPasswordComplexCharactersResult = rootPage.FindName("MinPasswordComplexCharactersResult") as TextBox;
                MinPasswordComplexCharactersResult.Text = ApplyResult.MinPasswordComplexCharactersResult.ToString();

                TextBox PasswordExpirationResult = rootPage.FindName("PasswordExpirationResult") as TextBox;
                PasswordExpirationResult.Text = ApplyResult.PasswordExpirationResult.ToString();

                TextBox PasswordHistoryResult = rootPage.FindName("PasswordHistoryResult") as TextBox;
                PasswordHistoryResult.Text = ApplyResult.PasswordHistoryResult.ToString();

                TextBox MaxPasswordFailedAttemptsResult = rootPage.FindName("MaxPasswordFailedAttemptsResult") as TextBox;
                MaxPasswordFailedAttemptsResult.Text = ApplyResult.MaxPasswordFailedAttemptsResult.ToString();

                TextBox MaxInactivityTimeLockResult = rootPage.FindName("MaxInactivityTimeLockResult") as TextBox;
                MaxInactivityTimeLockResult.Text = ApplyResult.MaxInactivityTimeLockResult.ToString();
            }
            catch (Exception Error)
            {
                //
                // Bad Parameter, COM Unavailable errors are to be handled here.
                //
                DebugPrint(Error.ToString());
            }

        }
Beispiel #2
0
        private async void Launch_Click2(object sender, RoutedEventArgs e)
        {
            try
            {
                Page outputFrame = (Page)rootPage.OutputFrame.Content;
                EasClientSecurityPolicy RequestedPolicy = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientSecurityPolicy();

                CheckBox RequireEncryptionValue = outputFrame.FindName("RequireEncryptionValue") as CheckBox;
                if (RequireEncryptionValue == null)
                {
                    RequestedPolicy.RequireEncryption = false;
                }
                else
                {
                    if (RequireEncryptionValue.IsChecked == true)
                    {
                        RequestedPolicy.RequireEncryption = true;
                    }
                    else
                    {
                        RequestedPolicy.RequireEncryption = false;
                    }
                }

                TextBox MinPasswordLengthValue = outputFrame.FindName("MinPasswordLengthValue") as TextBox;
                if (MinPasswordLengthValue == null || MinPasswordLengthValue.Text.Length == 0)
                {
                    RequestedPolicy.MinPasswordLength = 0;
                }
                else
                {
                    RequestedPolicy.MinPasswordLength = Convert.ToByte(MinPasswordLengthValue.Text);
                }

                CheckBox DisallowConvenienceLogonValue = outputFrame.FindName("DisallowConvenienceLogonValue") as CheckBox;
                if (DisallowConvenienceLogonValue == null)
                {
                    RequestedPolicy.DisallowConvenienceLogon = false;
                }
                else
                {
                    if (DisallowConvenienceLogonValue.IsChecked == true)
                    {
                        RequestedPolicy.DisallowConvenienceLogon = true;
                    }
                    else
                    {
                        RequestedPolicy.DisallowConvenienceLogon = false;
                    }
                }

                TextBox MinPasswordComplexCharactersValue = outputFrame.FindName("MinPasswordComplexCharactersValue") as TextBox;
                if (MinPasswordComplexCharactersValue == null || MinPasswordComplexCharactersValue.Text.Length == 0)
                {
                    RequestedPolicy.MinPasswordComplexCharacters = 0;
                }
                else
                {
                    RequestedPolicy.MinPasswordComplexCharacters = Convert.ToByte(MinPasswordComplexCharactersValue.Text);
                }

                TextBox PasswordExpirationValue = outputFrame.FindName("PasswordExpirationValue") as TextBox;
                if (PasswordExpirationValue == null || PasswordExpirationValue.Text.Length == 0)
                {
                    RequestedPolicy.PasswordExpiration = TimeSpan.Parse("0");
                }
                else
                {
                    RequestedPolicy.PasswordExpiration = TimeSpan.FromDays(Convert.ToDouble(PasswordExpirationValue.Text));
                }

                TextBox PasswordHistoryValue = outputFrame.FindName("PasswordHistoryValue") as TextBox;
                if (PasswordHistoryValue == null || PasswordHistoryValue.Text.Length == 0)
                {
                    RequestedPolicy.PasswordHistory = 0;
                }
                else
                {
                    RequestedPolicy.PasswordHistory = Convert.ToByte(PasswordHistoryValue.Text);
                }

                TextBox MaxPasswordFailedAttemptsValue = outputFrame.FindName("MaxPasswordFailedAttemptsValue") as TextBox;
                if (MaxPasswordFailedAttemptsValue == null || MaxPasswordFailedAttemptsValue.Text.Length == 0)
                {
                    RequestedPolicy.MaxPasswordFailedAttempts = 0;
                }
                else
                {
                    RequestedPolicy.MaxPasswordFailedAttempts = Convert.ToByte(MaxPasswordFailedAttemptsValue.Text);
                }

                TextBox MaxInactivityTimeLockValue = outputFrame.FindName("MaxInactivityTimeLockValue") as TextBox;
                if (MaxInactivityTimeLockValue == null || MaxInactivityTimeLockValue.Text.Length == 0)
                {
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.Parse("0");
                }
                else
                {
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.FromSeconds(Convert.ToDouble(MaxInactivityTimeLockValue.Text));
                }

                Windows.Security.ExchangeActiveSyncProvisioning.EasComplianceResults ApplyResult = await RequestedPolicy.ApplyAsync();



                TextBox RequireEncryptionResult = outputFrame.FindName("RequireEncryptionResult") as TextBox;
                RequireEncryptionResult.Text = ApplyResult.RequireEncryptionResult.ToString();

                TextBox MinPasswordLengthResult = outputFrame.FindName("MinPasswordLengthResult") as TextBox;
                MinPasswordLengthResult.Text = ApplyResult.MinPasswordLengthResult.ToString();

                TextBox DisallowConvenienceLogonResult = outputFrame.FindName("DisallowConvenienceLogonResult") as TextBox;
                DisallowConvenienceLogonResult.Text = ApplyResult.DisallowConvenienceLogonResult.ToString();

                TextBox MinPasswordComplexCharactersResult = outputFrame.FindName("MinPasswordComplexCharactersResult") as TextBox;
                MinPasswordComplexCharactersResult.Text = ApplyResult.MinPasswordComplexCharactersResult.ToString();

                TextBox PasswordExpirationResult = outputFrame.FindName("PasswordExpirationResult") as TextBox;
                PasswordExpirationResult.Text = ApplyResult.PasswordExpirationResult.ToString();

                TextBox PasswordHistoryResult = outputFrame.FindName("PasswordHistoryResult") as TextBox;
                PasswordHistoryResult.Text = ApplyResult.PasswordHistoryResult.ToString();

                TextBox MaxPasswordFailedAttemptsResult = outputFrame.FindName("MaxPasswordFailedAttemptsResult") as TextBox;
                MaxPasswordFailedAttemptsResult.Text = ApplyResult.MaxPasswordFailedAttemptsResult.ToString();

                TextBox MaxInactivityTimeLockResult = outputFrame.FindName("MaxInactivityTimeLockResult") as TextBox;
                MaxInactivityTimeLockResult.Text = ApplyResult.MaxInactivityTimeLockResult.ToString();
            }
            catch (Exception Error)
            {
                //
                // Bad Parameter, COM Unavailable errors are to be handled here.
                //
                DebugPrint(Error.ToString());
            }
        }
        private async void Launch_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                EasClientSecurityPolicy RequestedPolicy = new EasClientSecurityPolicy();

                if (RequireEncryptionValue == null)
                {
                    RequestedPolicy.RequireEncryption = false;
                }
                else
                {
                    if (RequireEncryptionValue.SelectedIndex == 1)
                    {
                        RequestedPolicy.RequireEncryption = true;
                    }
                    else
                    {
                        RequestedPolicy.RequireEncryption = false;
                    }
                }

                if (MinPasswordLengthValue == null || MinPasswordLengthValue.Text.Length == 0)
                {
                    RequestedPolicy.MinPasswordLength = 0;
                }
                else
                {
                    RequestedPolicy.MinPasswordLength = Convert.ToByte(MinPasswordLengthValue.Text);
                }

                if (DisallowConvenienceLogonValue == null)
                {
                    RequestedPolicy.DisallowConvenienceLogon = false;
                }
                else
                {
                    if (DisallowConvenienceLogonValue.SelectedIndex == 1)
                        RequestedPolicy.DisallowConvenienceLogon = true;
                    else
                        RequestedPolicy.DisallowConvenienceLogon = false;
                }

                if (MinPasswordComplexCharactersValue == null || MinPasswordComplexCharactersValue.Text.Length == 0)
                {
                    RequestedPolicy.MinPasswordComplexCharacters = 0;
                }
                else
                {
                    RequestedPolicy.MinPasswordComplexCharacters = Convert.ToByte(MinPasswordComplexCharactersValue.Text);
                }

                if (PasswordExpirationValue == null || PasswordExpirationValue.Text.Length == 0)
                {
                    RequestedPolicy.PasswordExpiration = TimeSpan.Parse("0");
                }
                else
                {
                    RequestedPolicy.PasswordExpiration = TimeSpan.FromDays(Convert.ToDouble(PasswordExpirationValue.Text));
                }

                if (PasswordHistoryValue == null || PasswordHistoryValue.Text.Length == 0)
                {
                    RequestedPolicy.PasswordHistory = 0;
                }
                else
                {
                    RequestedPolicy.PasswordHistory = Convert.ToByte(PasswordHistoryValue.Text);
                }

                if (MaxPasswordFailedAttemptsValue == null || MaxPasswordFailedAttemptsValue.Text.Length == 0)
                {
                    RequestedPolicy.MaxPasswordFailedAttempts = 0;
                }
                else
                {
                    RequestedPolicy.MaxPasswordFailedAttempts = Convert.ToByte(MaxPasswordFailedAttemptsValue.Text);
                }

                if (MaxInactivityTimeLockValue == null || MaxInactivityTimeLockValue.Text.Length == 0)
                {
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.Parse("0");
                }
                else
                {
                    RequestedPolicy.MaxInactivityTimeLock = TimeSpan.FromSeconds(Convert.ToDouble(MaxInactivityTimeLockValue.Text));
                }

                EasComplianceResults ApplyResult = await RequestedPolicy.ApplyAsync();

                RequireEncryptionResult.Text = ApplyResult.RequireEncryptionResult.ToString();
                MinPasswordLengthResult.Text = ApplyResult.MinPasswordLengthResult.ToString();
                DisallowConvenienceLogonResult.Text = ApplyResult.DisallowConvenienceLogonResult.ToString();
                MinPasswordComplexCharactersResult.Text = ApplyResult.MinPasswordComplexCharactersResult.ToString();
                PasswordExpirationResult.Text = ApplyResult.PasswordExpirationResult.ToString();
                PasswordHistoryResult.Text = ApplyResult.PasswordHistoryResult.ToString();
                MaxPasswordFailedAttemptsResult.Text = ApplyResult.MaxPasswordFailedAttemptsResult.ToString();
                MaxInactivityTimeLockResult.Text = ApplyResult.MaxInactivityTimeLockResult.ToString();
            }
            catch (Exception Error)
            {
                rootPage.NotifyUser(Error.Message, NotifyType.ErrorMessage);
            }
        }