“权限不足,无法完成操作。”尝试以编程方式创建新的Azure AD应用程序时

时间:2018-08-20 12:09:24

标签: azure-active-directory

我正在尝试以编程方式创建Azure AD应用程序(C#-脚本) 我已经将对AddApplicationAsync的调用包装在try-catch中

当我运行它时,我收到异常消息“权限不足,无法完成操作。”,

public void CreateNewClientApplication(string pName, Guid pResourceAppId)
        {
            var newClientApp = new Application();
            newClientApp.DisplayName = pName;
            newClientApp.ReplyUrls.Add(CreateDummyReplyUrl(pName));

            newClientApp.PasswordCredentials = new List<PasswordCredential>() {
                new PasswordCredential()
                {
                    Value = "xxxxxxxxx",
                    KeyId = Guid.NewGuid(),
                    StartDate = DateTime.UtcNow,
                    EndDate = DateTime.UtcNow.AddYears(2),
                }
            };

            RequiredResourceAccess resource = new RequiredResourceAccess();
            resource.ResourceAppId = pResourceAppId.ToString();
            newClientApp.RequiredResourceAccess.Add(resource);

            var activeDirectoryClient = AuthenticationHelper.GetActiveDirectoryClientAsApplication();
            try
            {
                activeDirectoryClient.Applications.AddApplicationAsync(newClientApp).Wait();
            }
            catch (Exception ex)
            {
                 // EXCEPTION-MESSAGE: "Insufficient privileges to complete the operation."
            }

        } 

所以我的问题是,需要什么权限? 我有这些

enter image description here

0 个答案:

没有答案