private async Task SignOutAsync() { // Apply the Default role, which is represented by Guid.Empty. // The Default role is the one that is used when nobody is signed in. // Note that successfully applying the profile will result in the termination of all running apps, including this sample. await DeviceLockdownProfile.ApplyLockdownProfileAsync(Guid.Empty); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (tenant == "contoso.onmicrosoft.com" || clientId == "{...}") { // The user has not configured the sample for Azure Authentication. UseAzureAuthenticationCheckBox.IsEnabled = false; UseAzureAuthenticationCheckBox.IsChecked = false; rootPage.NotifyUser("This sample has not been configured for Azure Authentication.", NotifyType.ErrorMessage); } try { // If the current role is Guid.Empty, then the user is not signed in. Guid currentRole = DeviceLockdownProfile.GetCurrentLockdownProfile(); if (currentRole == Guid.Empty) { SignInStatus.Text = "You are not signed in."; canSignOut = false; } else { DeviceLockdownProfileInformation currentProfile = DeviceLockdownProfile.GetLockdownProfileInformation(currentRole); SignInStatus.Text = "You are signed in as " + currentProfile.Name; canSignOut = true; } SignOutButton.IsEnabled = canSignOut; LoadApplicationUsers(); } catch (System.IO.FileNotFoundException) { rootPage.NotifyUser("Assigned Access is not configured on this device.", NotifyType.ErrorMessage); } }
private async Task SignInAsync() { // Extract the name and role of the item the user selected. ListBoxItem selectedItem = (ListBoxItem)UserRoles.SelectedItem; string selectedName = (string)selectedItem.Content; Guid selectedRole = (Guid)selectedItem.Tag; bool canSignIn; if (UseAzureAuthenticationCheckBox.IsChecked.Value) { canSignIn = await AuthenticateAzureRole(selectedRole, selectedName); } else { // If the sample should use local authentication, // then do some app-specific authentication here. // For this sample, we just assume anybody can sign in as any role. canSignIn = true; } if (canSignIn) { // Note that successfully applying the profile will result in the termination of all running apps, including this sample. await DeviceLockdownProfile.ApplyLockdownProfileAsync(selectedRole); } }
private void LoadApplicationUsers() { // Add the available roles. foreach (Guid roleId in DeviceLockdownProfile.GetSupportedLockdownProfiles()) { DeviceLockdownProfileInformation profile = DeviceLockdownProfile.GetLockdownProfileInformation(roleId); UserRoles.Items.Add(new ListBoxItem() { Content = profile.Name, Tag = roleId }); } // If there are roles available, then pre-select the first one and enable the Sign In button. if (UserRoles.Items.Count > 0) { UserRoles.SelectedIndex = 0; SignInButton.IsEnabled = true; } }