Skip to content

Commit

Permalink
Swiping clean-up
Browse files Browse the repository at this point in the history
- FIxing a typo in AppCreationScripts.md
- Fixing the configuration of the SPA code (in the Configure.ps1 script)
- Improving slighly the Readme.md
  • Loading branch information
jmprieur committed Apr 6, 2018
1 parent c62ef99 commit ad85967
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion AppCreationScripts/AppCreationScripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here are the details on how to do this.
#### Option 1 (interactive)
- Just run ``. .\Configue.ps1``, and you will be prompted to sign-in (email address, password, and if needed MFA).
- Just run ``. .\Configure.ps1``, and you will be prompted to sign-in (email address, password, and if needed MFA).
- The script will be run as the signed-in user and will use the tenant in which the user is defined.
Note that the script will choose the tenant in which to create the applications, based on the user. Also to run the `Cleanup.ps1` script, you will need to re-sign-in.
Expand Down
8 changes: 6 additions & 2 deletions AppCreationScripts/Configure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ Function GetRequiredPermissions([string] $applicationDisplayName, [string] $requ
Function UpdateLine([string] $line, [string] $value)
{
$index = $line.IndexOf(':')
$delimiter = ','
if ($index -eq -1)
{
$index = $line.IndexOf('=')
$delimiter = ';'
}
if ($index -ige 0)
{
$line = $line.Substring(0, $index+1) + " """+$value + ""","
$line = $line.Substring(0, $index+1) + " "+'"'+$value+'"'+$delimiter
}
return $line
}
Expand Down Expand Up @@ -152,6 +154,8 @@ Function ConfigureApplications
-ReplyUrls "https://MyDirectorySearcherApp" `
-AvailableToOtherTenants $True `
-PublicClient $True


$currentAppId = $clientAadApplication.AppId
$clientServicePrincipal = New-AzureADServicePrincipal -AppId $currentAppId -Tags {WindowsAzureActiveDirectoryIntegratedApp}
Write-Host "Done."
Expand All @@ -160,9 +164,9 @@ Function ConfigureApplications
$clientPortalUrl = "https://portal.azure.com/#@"+$tenantName+"/blade/Microsoft_AAD_IAM/ApplicationBlade/appId/"+$clientAadApplication.AppId+"/objectId/"+$clientAadApplication.ObjectId
Add-Content -Value "<tr><td>client</td><td>$currentAppId</td><td><a href='$clientPortalUrl'>MyDirectorySearcherApp</a></td></tr>" -Path createdApps.html

$requiredResourcesAccess = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.RequiredResourceAccess]
# Add Required Resources Access (from 'client' to 'Microsoft Graph')
Write-Host "Getting access from 'client' to 'Microsoft Graph'"
$requiredResourcesAccess = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.RequiredResourceAccess]
$requiredPermissions = GetRequiredPermissions -applicationDisplayName "Microsoft Graph" `
-requiredDelegatedPermissions "User.Read|User.ReadBasic.All";
$requiredResourcesAccess.Add($requiredPermissions)
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Once you've completed your IDE setup, from your IDE or the command-line, run:

or download and extract the repository .zip file.

> Given that the name of the sample is pretty long, and so are the name of the referenced NuGet pacakges, you might want to clone it in a folder close to the root of your hard drive, to avoid file size limitations on Windows.

### Step 3: Create user(s) in your Azure Active Directory tenant

For this sample, you must have at least one user homed in the AAD tenant in which you will register the application. You can't run the sample with your Microsoft Account, so create a new user with the same domain as your tenant if necessary.
Expand All @@ -67,6 +70,9 @@ This step and the following are optional. Indeed, the sample is configured to ru
1. Sign in to the [Azure portal](https://portal.azure.com).
1. On the top bar, click on your account and under the **Directory** list, choose the Active Directory tenant where you wish to register your application.
1. Click on **All services** in the left-hand nav, and choose **Azure Active Directory**.

#### Register the client app (MyDirectorySearcherApp)

1. In the **Azure Active Directory** pane, click on **App registrations** and choose **New application registration**.
1. Enter a friendly name for the application, for example 'MyDirectorySearcherApp' and select 'Native' as the *Application Type*.
1. For the *Redirect URI*, enter `https://<your_tenant_name>/MyDirectorySearcherApp`, replacing `<your_tenant_name>` with the name of your Azure AD tenant.
Expand All @@ -82,10 +88,13 @@ This step and the following are optional. Indeed, the sample is configured to ru

### Step 5: Configure the sample to use your Azure AD tenant

1. Open the solution in Visual Studio 2015.
2. Open the `DirectorySearcherLib\DirectorySearcher.cs` file in the `DirectorySearcherLib (Portable)` project.
3. Find the `clientId` member variable and replace its value with the Client ID you copied from the Azure portal.
4. Find the `returnUri` member variable and replace the value with the redirect Uri you registered in the Azure portal.
In the steps below, ClientID is the same as Application ID or AppId.

Open the solution in Visual Studio to configure the projects

1. Open the `DirectorySearcherLib\DirectorySearcher.cs` file in the `DirectorySearcherLib (Portable)` project.
1. Find the `clientId` member variable and replace its value with the Client ID you copied from the Azure portal.
1. Find the `returnUri` member variable and replace the value with the redirect Uri you registered in the Azure portal.

### Step 6: Run the sample(s)

Expand Down

0 comments on commit ad85967

Please sign in to comment.