Skip to content

Commit 627ec85

Browse files
committed
- Using the recommanded pattern to acquire the token (AcquireTokenSilent first)
- Improving the layout as the search status was troncated vertically
1 parent 1560951 commit 627ec85

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

DirSearchClient-Universal/MainPage.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<Grid Grid.Row="1" x:Name="SearchRoot" Margin="20,20,20,0">
2727
<Grid.RowDefinitions>
2828
<RowDefinition Height="80" />
29-
<RowDefinition Height="40" />
29+
<RowDefinition Height="50" />
3030
</Grid.RowDefinitions>
3131
<Grid Grid.Row="0" x:Name="searchRow">
3232
<Grid.ColumnDefinitions>

DirectorySearcherLib/DirectorySearcher.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ public static async Task<List<User>> SearchByAlias(string alias, IPlatformParame
2525
AuthenticationResult authResult = null;
2626
JObject jResult = null;
2727
List<User> results = new List<User>();
28+
AuthenticationContext authContext = new AuthenticationContext(commonAuthority);
2829

2930
try
3031
{
3132
// To avoid the user consent page, input the values for your registered application above,
3233
// comment out the if statement immediately below, and replace the commonAuthority parameter
3334
// with https://login.microsoftonline.com/common/<your.tenant.domain.com>
34-
AuthenticationContext authContext = new AuthenticationContext(commonAuthority);
3535
if (authContext.TokenCache.ReadItems().Count() > 0)
3636
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
37+
authResult = await authContext.AcquireTokenSilentAsync(graphResourceUri, clientId);
38+
}
39+
catch(AdalSilentTokenAcquisitionException)
40+
{
3741
authResult = await authContext.AcquireTokenAsync(graphResourceUri, clientId, returnUri, parent);
3842
}
3943
catch (Exception ee)

0 commit comments

Comments
 (0)