我想使用Windows Azure Active Directory(WAAD)圖形API向我的WAAD租戶添加應用程序。我已成功使用該API創建用戶。當使用API添加一個應用程序,我收到一條授權異常:Windows Azure圖形API添加應用程序
Authorization_RequestDenied:權限不足來完成操作
執行相同的步驟來添加用戶工作無異常。
我按照這裏的指導:http://msdn.microsoft.com/en-us/library/windowsazure/dn151791.aspx#BKMK_Configuring和樣本在這裏:http://code.msdn.microsoft.com/Write-Sample-App-for-79e55502上手。
這裏是我的代碼示例:
//get the tenantName
var tenantName = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
// retrieve the clientId and password values from the Web.config file
var clientId = ConfigurationManager.AppSettings["ClientId"];
var password = ConfigurationManager.AppSettings["Password"];
// get a token using the helper
var token = DirectoryDataServiceAuthorizationHelper.GetAuthorizationToken(tenantName, clientId, password);
// initialize a graphService instance using the token acquired from previous step
var graphService = new DirectoryDataService(tenantName, token);
// Create and save the application
var application = new Application();
application.availableToOtherTenants = false;
application.displayName = "some display name";
application.homepage = "https://localhost/";
application.identifierUris.Add("https://localhost/");
application.replyUrls.Add("https://localhost/");
graphService.AddTodirectoryObjects(application);
graphService.SaveChanges();
我需要設置權限,允許通過圖形API的應用程序的創建?我無法在Azure管理控制檯中找到允許我執行此操作的位置。
我是否使用正確的代碼來添加應用程序?有關如何使用應用程序的示例並不多。我假設我需要使用AddTodirectoryObjects來保存應用程序,因爲我沒有找到應用程序的「AddTo ...」方法。
這是問題所在。我使用PowerShell更新角色。 http://technet.microsoft.com/en-us/library/jj151815.aspx。 'Add-MsolRoleMember -RoleName「公司管理員」-RoleMemberType ServicePrincipal -RoleMemberObjectId ...' – mskutta