Dynamics 365 WebAPI - How to get user access to an entity? - dynamics-crm

How can I retrieve the user access for an entity using Dynamics Web API? I am using v9.0
ie; Check if a user have read / create / edit access for an entity.

These web api endpoints will help you to understand the things & achieve what you want.
https://crmdev.crm.dynamics.com/api/data/v9.1/systemusers(3bd2aded-20b2-e911-a98e-000d3a374b53)/Microsoft.Dynamics.CRM.RetrieveUserPrivileges()
https://crmdev.crm.dynamics.com/api/data/v9.1/privileges?$select=name
For ex. When I pass my System User GUID to the first function - the second url result says I have Global (Organisation) level Create privilege.
{"Depth":"Global","PrivilegeId":"a8bff87f-0df0-41d4-babd-f093faf1e32c","BusinessUnitId":"b08c8c6c-5c20-e511-80f7-c4346bac59ac"}
{"#odata.etag":"W/\"101387508\"","name":"prvCreateContact","privilegeid":"a8bff87f-0df0-41d4-babd-f093faf1e32c"}
Glossary:
Basic (User)
Local (Business Unit)
Deep (Parent: Child)
Global (Organisation)

Related

How to grant read-write access request to a specific record of an entity to an user in Dynamics 365?

In Dynamics-365 crm, I want to grant read-write access request to an user of D-365 to a specific record of an entity if the user is not privileged with that privileges.
I did that by assigning some sort of security roles to that user. But I can't do that by modifying security role.
So how can I do that without assigning security role?
You can achieve the same share functionality in code using GrantAccessRequest, refer my another Stack Overflow answer for C# plugin example.
For web api, your org has to be greater than v9.0 as GrantAccess message was not available in web api till v8.2
Still to achieve this object based security model, you should give users privilege to read-write that entity records through role based security model. Without user having entity edit privilege in security role they cannot edit by getting record sharing.
Read more: Use record-based security to control access to records
If you do not wish to change/update your security Roles, then you can do so by sharing a particular Record with Either Team or User.Below 2 images will help you explain how to share a Record.
Now this process below is manual and you could achieve this process programmatically as well using C# i.e server side coding
Note:
If this solves your problem do mark this answer as solved.

How to get roles assigned for an user in Office 365 environment from Powerapps

We are trying to change Button Visibility Based on User Role. Added Custom Security Role, Assigned roles to Users from Dynamics 365 environment .
Custom Security roles
Assigned These roles to Users via Manage Roles option.
Manage User Roles
How can we get Role assigned for CurrentUser in Powerapps Environment? Only 3 attributes(Email,fullName,Image) are available for User() object. Tried using Dynamics 365 Users, Security roles etc into Datasource. Also tried by adding Users entity into Datasource.
Dynamics 365 security roles, users in to datasource
In a classic Dynamics CRM web UI or Model driven PowerApp, we have a choice to write client side form scripting to pull current user’s security roles and manipulate the client controls. We will be using web api or odata & utilize the systemuserrolescollection or SystemUserRolesSet dataset to pull the needed data. Read more
But in Canvas apps, even today we are unable to find this System user roles table in Dynamics 365 connectors. So we have to wait till this is exposed.
Or you can have a SQL replication (maybe Data export service) or custom connector which consume the D365 web api to pull this data.

How to create multiple entities of same type in a single go in CRM online?

I am integrating MS Dynamics CRM online with my ASP.Net MVC application. I am creating a synchronization process between both. I'm stuck at the point where
I need to check if user has entered valid CRM credentials ie. server address, domain, username and password etc. I am not sure which class is to use for that?
I want to create multiple entities of same type in a single go in CRM online from my Application. Currently I am using ServiceProxy's Create() method to do so . How can I create , for instance, 10 contacts in a single request ?
Is there any way to send list of objects to CRM server and create
them there?
To check I believe the easiest way is just execute call for example of WhoAmI message. If it would not throw an exception - that will mean that credentials are correct.
You should look at ExecuteMultiple message.

Changing request level for google project

How do I lower the requested access level of an existing google project?
It's currently asking for:
View your email address
View your basic profile info
Manage your contacts
When all I really want is to authenticate a user for login purposes, and I think all I need for that is:
Have offline access
One of the parameters you are passing when you create a credential is called scope, and contains a list of each of the services your users must authorize.
From the OAuth 2.0 docs, scope contains a string or iterable of strings. Change it to the new scopes you want.

Access User details in membership of Asp.Net MVC application

I am using the default membership authorization that is created when you start a new project in VS for MVC 3. When a user is registered (either if I do it for them in the Administration page or if they register themselves through the Register page created in the application), there is an email field for instance. But where is this stored? Shouldn't I be able to access that e-mail somehow? I can't find it in the User object...
Also, is it possible to add more fields when they register, and to access those as well? For instance address, phone number, etc?
1. Getting the e-mail
You can access the property from the current user by using the Membership object.
Membership.GetUser().Email
2. Extra Fields
The best way to add more fields to the register process is to make another model called UserDetail or something. And make a relationship between User and UserDetail.
Or you throw away the default membership authorization and make a custom one. Here are some handy links:
http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
http://www.asp.net/learn/videos/video-189.aspx
http://www.15seconds.com/issue/050216.htm
http://davidhayden.com/blog/dave/archive/2007/10/11/CreateCustomMembershipProviderASPNETWebsiteSecurity.aspx
For the extra user fields you can use the ASP.NET profile provider.
here is a good article about how to implement it:
http://ashuthinks.wordpress.com/2012/01/08/asp-net-mvc-profile-provider/

Resources