How to create Dynamics CRM Online User License
来源:互联网 发布:淘宝店铺图标素材 编辑:程序博客网 时间:2024/05/17 17:40
Hi, guys. Today I would like to share your guys how to operate CRM Online through O365 APIs. This is a very new topic because O365 APIs just went into Preview program.
Can we create CRM online user using CRM OOB APIs? No, imagine that if you want to create a user in on premise environment, then you should create an account in AD first, and then create an CRM account using created AD account. As same as on premise environment, we also need to create an online AD account in Azure AD first.
OK, let's break up the confused concept. What's O365 APIs? O365 is office 365, Microsoft was migrated all of office suit software e.g. word, excel, sharepoint, exchange and so on into Cloud environment. And they are got very user experience for integration. Image that you just need to buy one software, and then you can use all of competition software on longer do anything for configurations or setups. For O365 APIs, it was expose to end-developer to invoke to control resources of Office 365 such creating an calendar, sending email, creating user, assigning user license and so on.
In this article, we will follow below steps to describe this topic:
1. How to invoke O365 APIs.
Microsoft had published one VS extension tool. It can generate sample codes about how to invoke O365 services.
2. How to use O365 APIs to create CRM Online user
Right now Microsoft was expose oen type APIs called Azure AD graph based web api to us to operate CRM Online user. And there is one helper library can be used to operate CRM Online user, you guys can download it in here. Below is a code snipet about how to user it to create CRM Online user.
string userName = new Random().Next(1000, 9999).ToString(); var verifiedDomains = DDS.tenantDetails.Single().verifiedDomains.ToList(); var verifiedDomainValues = verifiedDomains.Select(it => it.name); ViewData["selectedDomain"] = new SelectList(verifiedDomainValues); Microsoft.WindowsAzure.ActiveDirectory.User user = new Microsoft.WindowsAzure.ActiveDirectory.User(); user.userPrincipalName = string.Format(CultureInfo.InvariantCulture, "{0}@{1}", userName, "crm2014.onmicrosoft.com"); user.mailNickname = userName; user.displayName = userName; user.accountEnabled = true; user.passwordProfile.password = "123456"; DDS.AddTousers(user); DDS.SaveChanges();
3. How to assign O365 license to created CRM Online user
We still can't use the created account after assiging a license to it. So we need to use below code to assign a license to the created account.
string[] queryParameters = { "api-version=2013-11-08" }; string requestUrl = String.Format(CultureInfo.InvariantCulture, "{0}/{1}/users/{2}/assignLicense?{3}", serviceInfo.ApiEndpoint, HttpUtility.UrlEncode(Office365CommonController.TenantId), HttpUtility.UrlEncode(user.userPrincipalName), String.Join("&", queryParameters)); // Prepare the HTTP request: using (HttpClient client = new HttpClient()) { Func<HttpRequestMessage> requestCreator = () => { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl); request.Content =new StringContent(@"{ 'addLicenses':[{'disabledPlans':[ ],'skuId':'d17b27af-3f49-4822-99f9-56a661538792'}], 'removeLicenses':[ ]}",System.Text.Encoding.UTF8,"application/json"); return request; }; // Send the request using a helper method, which will add an authorization header to the request, // and automatically retry with a new token if the existing one has expired. using (HttpResponseMessage response = await Office365CommonController.SendRequestAsync( serviceInfo, client, requestCreator)) { // Read the response and deserialize the data: string responseString = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { return Office365CommonController.ShowErrorMessage(serviceInfo, responseString); } return View(); } } }
Resources
Office 365 APIsAuthority Documents
http://msdn.microsoft.com/en-us/library/office/dn605892.aspx
Office 365 API forVisual Studio 2013 Extension
http://visualstudiogallery.msdn.microsoft.com/7e947621-ef93-4de7-93d3-d796c43ba34f
Office 365 API Workthrough
http://blogs.msdn.com/b/officeapps/archive/2014/03/12/announcing-office-365-api-tools-for-visual-studio-preview.aspx
Announcing the new version of the Graph API: api-version=2013-11-08( how to assign license to users)
http://blogs.msdn.com/b/aadgraphteam/archive/2013/11/14/announcing-the-new-version-of-the-graph-api-api-version-2013-11-08.aspx>
- How to create Dynamics CRM Online User License
- Dynamics CRM JS 信息提示框(How Do You Create Alerts with Microsoft Dynamics CRM Javascript)
- How to create a user in PostgreSQL
- How to create ftp user on Linux
- How to create a remote desktop user
- Dynamics CRM Online Administrator password reset
- How to Create Websites——W3Schools Online Web Tutorials
- How to use Microsoft Dynamics Connector to sync data between different crm organizations
- How To Create An SYSASM User On Release 11g
- User Xcode and GCC How to create a C programe
- How to create user defined properties in Maven
- Dynamics CRM 2015 Online Update1 UI界面的更新变化
- 使用FetchXML制作Dynamics CRM Online 高级报表
- Dynamics CRM Online 10 Data Export and Import Redesign Features
- Adding Outlook Contacts to Dynamics CRM 2011
- SAP CRM How to Create your own BOL Object for webclient
- Dynamics CRM2016 New features in Microsoft Dynamics CRM Online 2015 Update 1 are now available
- you have to know about how to create user defined control.
- Neutron L3 agent HA
- 关于Asp.Net中FileUpload控件属性PostedFile.ContentType的提示
- MySql日期操作
- 第三章作业(改)
- zedboard OPENCV移植
- How to create Dynamics CRM Online User License
- 将Sublime Text 2搭建成一个好用的IDE
- android 瀑布流效果(仿蘑菇街)
- 第六周作业
- php开发框架 yii框架搭建(windows 和Linux)
- 学习PHP图像处理(验证码)
- 函数指针和指针函数
- 索引
- 使用ScheduledExecutor和Calendar实现复杂任务调度