# Grant Access to Selected Sites

If you want to grant users access to specific SharePoint sites through the Azure portal, follow the steps below:

1. Create connector for respective SharePoint site in Attach2Dynamics. Follow this[ link ](https://docs.inogic.com/attach2dynamics/configuration/connector-configuration/sharepoint)to know how to create connector.

{% hint style="info" %}
**Note: For enabling this feature user must set “Allow Permission for Selected Site” field to “Yes”. This field is hidden on the form and user must make this field visible for enabling it.**
{% endhint %}

2. Create azure app

Please follow the below steps to create Azure Active Directory (AAD) app:

Step 1 – Login into Azure portal – <https://portal.azure.com/>

Step 2 – Click on Azure Active Directory.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F4Mi3RApCfuH8RjyTpKEG%2F1.png?alt=media&#x26;token=785d85b3-bd0f-4018-830c-4a10fc132656" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

Step 3 – Navigate to App registrations and then click on new registration.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F4ae8LRIGQwWcsYKyMCmZ%2F2.png?alt=media&#x26;token=abf3ca7d-2ee4-4693-988a-b784e1684cfa" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* **Name:** Give a desired display name for the App.
* **Redirect URL:**  Copy and paste the **Redirect URL** from the [credentials tab of the connector form](https://docs.inogic.com/attach2dynamics/configuration/connector-configuration/sharepoint).

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FtX3Hq972fDtmMVgAsXJ3%2Fimage.png?alt=media&#x26;token=fb99ad23-dfab-42ba-93a9-ff8f04bdc736" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Now click on **“Register”** button.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FGg78WEZmw6lz9C33nwMh%2F3.png?alt=media&#x26;token=62ee4aa8-33a9-4435-aef4-85893fb64f77" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

Step 4 – Now you need to give some permissions to app. So, navigate to API permissions. Here you need to go to **“Add Permission”** for Dynamics 365 CRM and SharePoint.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FdxuSjfZTSI91L2pDKdd9%2F4.png?alt=media&#x26;token=12cb2348-cc0b-4a71-8a77-5138780dd574" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

• To add permissions, click on **Dynamics CRM.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FgpES7zYAFcyAs3dz1Bvo%2F5.png?alt=media&#x26;token=d3b9c3f8-cc3c-49de-9e8d-d18cd1d113de" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Grant **User Impersonation** access.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FxFmpDhwDIx1izC2Oofvp%2F6.png?alt=media&#x26;token=a6b86d39-a69b-45de-b625-39f40cbc5524" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* To add SharePoint permissions, navigate to **Microsoft Graph.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FRJUYTzZQywfIwk2s4vxn%2F7.png?alt=media&#x26;token=c1911628-2bc4-48dc-95b6-481047640d82" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Select **“Application Permissions.”**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FuupbCEnUNhAZ1sYITuk1%2F8.png?alt=media&#x26;token=c45435ff-2100-468c-ac5d-d87864a4d83c" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* To grant users access to selected sites, select **“Sites.Selected”** permission.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FlJ2njBydbuVQ7Sr1qYFi%2F9.png?alt=media&#x26;token=a6de8d84-0f26-437a-bdd8-b1d9e8239c3c" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Select **“Delegated Permissions.”**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FXG2xGO7LmrXo85jN6pQh%2FA2D%20%201.png?alt=media&#x26;token=a78d567b-1cf1-4f40-bf83-f1abf0c35774" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* To grant users access to selected sites, select **“Sites.Selected”** permission, and click on **“Add Permissions”.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F5KQ6dFmR8z4SjKn2OmVq%2FA2D%202.png?alt=media&#x26;token=693e9d08-0888-4cb8-888c-c5cf8de0606a" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Navigate to **SharePoint.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FCtrEf9GNTDTWgy6mOYN8%2F10.png?alt=media&#x26;token=28269ba8-6395-4b46-bf68-4de036c2c897" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Select "**Application Permission."**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FFXPd9M05xT8bamRbenDB%2F11.png?alt=media&#x26;token=ce965dc1-483f-43db-9196-80dfcbf15cbe" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

• To grant users access to selected sites, select **“Sites.Selected"** permission.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FNGjbMHi1feu2TcmA8PQz%2F12.png?alt=media&#x26;token=13fd07e9-b3c5-49ec-9034-ef3b0805d327" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Click on **“Grant admin consent”** button as shown below.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FiTW7DlfFAxpkPxuJZYlQ%2F13.png?alt=media&#x26;token=14082c3f-bd83-479b-ac2d-cd36f4ba2834" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Navigate to **“Authentication”,** enable **Access Tokens**, and click on **‘Save’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FQUdVF9CgUG28s6TKA4qf%2F14.png?alt=media&#x26;token=f39b2c79-95bc-4195-9ab9-17f297a97f47" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Now, navigate to **Certificate & Secrets** and click on **New client secret** to create a secret key.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F2hzy5m26hxiNruH3nDXH%2F15.png?alt=media&#x26;token=526f9324-b524-4e59-8b07-a718b62e8d70" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

{% hint style="info" %}
**Note: Please copy the secret key immediately and keep it for future reference as it will disappear after some time.**
{% endhint %}

* Copy the **“Application ID”** and **“Secret Key”.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F25ssa7npNaadS8JdsIWI%2F16.png?alt=media&#x26;token=e08600fd-9903-47d6-9880-b614fa60204a" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Go to Dynamics 365 CRM and navigate to **Attach2Dynamics app ->** **Connector Entity -> Credentials Tab** and paste both **“Application ID”** and **“Secret Key”.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F6ldEXu6OjVorFeHzXLWz%2F17.png?alt=media&#x26;token=6f03ac96-52a5-4da7-815b-f59bed1de953" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* To authenticate the connector, you’ll first need to run a PowerShell script.
* Download the PowerShell script from [here](https://inogicindia-my.sharepoint.com/:u:/g/personal/storage_inogic_com/EezxavWNk8hLnn8Un2cdEVYBhP5X1Ag5gjLbTMM_2y9mzA?e=T4euG2\&download=1).

{% hint style="info" %}
**Note: User need to install PowerShell version 7.0 and above.**
{% endhint %}

* Once you have installed PowerShell on your device. Open the PowerShell command window and select **“Run as Administrator”.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FyeUPHV5jFEMaeMyzj6ep%2F18.png?alt=media&#x26;token=c32fd7e9-6adf-42bd-aa3c-e6985ca0e176" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

• Now enter the syntax as **&”file path\PowerShell script name”** and click **‘Enter’** to **Run** the command.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FGdQNlajihH8dYngbrHNR%2F19.png?alt=media&#x26;token=44d012b9-a2e6-4069-a70c-e9724d0ccbc2" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

{% hint style="info" %}
**Note: Enter the file path where you have stored the PowerShell script in your device and the name of the PowerShell script in the above syntax.**
{% endhint %}

* Now, in the PowerShell command window, enter the following details:
  * SharePoint site URL
  * Azure App ID
  * Tenant Name
  * Secret key of Azure App
  * Display name of Azure App

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FBjv220wZMHO6wVQ3CpCJ%2F20.png?alt=media&#x26;token=a2c514bc-c44f-462b-98fc-ccc3ff56982d" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* A Pop-up window will appear. Fill in your credentials and then a confirmation Pop-up will be opened. In the Pop-up, please select **Consent on behalf of your organization** --> Click on the **Accept** button.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FuNHCMUMR51UdsdFvWOn2%2F21.png?alt=media&#x26;token=49b53f25-f264-4c92-b634-96fa1529d5ce" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F4UVzrLEpUraeMlcRTxGe%2F22.png?alt=media&#x26;token=3e8bc89d-8987-4337-ae81-b299cc8efcb4" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* Once the script has been executed successfully, you will be able to see **“Completed”** message on the command window, as shown in the below image.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FkpEAzUsYaD8EQJn1WYHF%2F23.png?alt=media&#x26;token=240a1a20-bd56-4bca-a4b6-dc812b9b73d7" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

• Once the script has been successfully executed navigate to **Attach2Dynamics App -> Connectors entity**, and click on the **Authenticate** Button.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FmACIAAn7rORzhJgohSpD%2F24.png?alt=media&#x26;token=5eac2a32-fe26-4281-858b-b60acfc088fe" alt="Grant Access to Selected Sites"><figcaption></figcaption></figure>

* After clicking on the Accept button if the credentials are correct then you will get a Success message window.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FHkydYjxnBmTw6ipf8V9W%2F25.png?alt=media&#x26;token=bddd37d5-d0b2-436f-98d8-90c39e4663db" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
For any queries, reach out to us at <crm@inogic.com>
{% endhint %}
