Getting blank while fetching Delegated permissions of Service Principal via PowerShell - azure-ad-powershell-v2

I am trying to get the list of delegated permissions that I granted to Service principal by querying via PowerShell like below:
Get-AzureADOAuth2PermissionGrant | Where-Object { $_.ClientId -eq 'myappclientid' } | Select-Object -Property *
But I am getting blank in response.
I can see the Service principal permissions in my Azure Portal. But still, I'm facing the same error.
Can anyone help me out with what am I missing here?
I'm giving ObjectID of my application registered in Azure AD like this:

Please note that when you are registering application in Azure AD it automatically creates a Service Principal under Enterprise Applications with same name but with different object_id
Make sure to pass that object_id of your Enterprise application not your registered application like below:
Go to Azure Portal -> Azure Active Directory -> Enterprise Applications -> Your Application -> Overview
I tried to reproduce the same in my environment and got the below results:
When I passed object_id of registered application in the query like below I got the same response like below:
When I passed the object_id of Enterprise application, I got the delegated permissions successfully like below:
References:
Apps & service principals in Azure AD - Microsoft Entra | Microsoft Docs
azure - How to list Service principal permissions using powershell - Stack Overflow by fabrisodotps1

Related

Failed changing Windows service credentials to gsma

I am having an error when trying to reinstall the AADConnectProvisioningAgentSetup installer. Please see image below:
Failed changing Windows service credentials to GMSA. Please check the logs for more detailed information...
To resolve this issue,
Check the System event logs for EventID 7041.The event details provide instructions on how to create a Log on as a service user directly within the Local Security Policy (secpol.msc) like below:
Ref: Azure AD Hybrid Sync Agent Installation Issues - The gMSA is set to log on as Service - Active Directory | Microsoft Learn
Solution 2: Try to generate the KDS Root Key by using below command:
Add-KdsRootKey -EffectiveTime ((get-date).addhours(-10))
If a KDS root key was already created by you, Use the Get-KdsRootKey cmdlet to verify the root keys already present on a few DCs like below:
If you are trying to utilize an existing GMSA account, use below comment to test sync agent:
Test-ADServiceAccount -Identity serviceAccountgMSA$
As per reference doc by Daniel try to check your FOREST functional level like below:
In server manager -> Tools -> Active Directory Domains and Trusts -> Raise Forest Functional Level
Reference:
Azure Active Directory Provision Agent Install failing by Serenityadmin

Is it possible to login with an azure ad account, via the azure cli while running as the "NT Authority\Network Service" user?

I work in a team that uses Azure Service Fabric and I want to connect to an Azure SQL database using my Azure AD account instead of using a SQL username/password when running locally.
Service Fabric runs locally on a cluster and runs as the NT Authority\Network Service user. I believe that it's possible to change the user that it runs under, but when I tried it seemed to remove the ability to use Visual Studio to debug the app. It also required having the password in the config which is not ideal.
I'm trying to login to Azure AD with the AzureCli and the az login command and can do this easily with my local user azuread\chester.
A comment on github suggests that I should be able to run a powershell prompt as the network service and use az login to login with my account. When I tried this it failed with a generic error:
Does anyone know if it's possible to login to AzureAD with the NT Authority\Network Service user?
I know it's possible to use an Azure App Registration as a principal, but this method still involves a password and i'm trying to avoid passwords.
It is perfectly possible but, since it's a non-interactive account, the optimal choice is to login as an application. This, however, implies high level permissions so careful attention must be paid when consenting them. Also, it's possible to login as a user using the ROPC flow, however this one is not recommended due security and technical limitations.
Regarding az cli take a look at Sign in with a service principal.

Android Management API: Failed to patch policy - Caller is not authorized to manage enterprise

I have been working with the Android Management API to try and manage the policy of my company's existing enterprise. My company account has the Owner role within the organization and the roles Owner and Service Account Admin for the service account mentioned later.
I followed the Quickstart Guide to get familiar with the API and made some modifications for a more permanent solution along the way such as creating a service account with the Android Management User role via the Google Cloud Platform and generating a JSON key to acquire credentials rather than going through the OAuth2 flow like in the guide. This allowed me to authenticate properly, but when it comes time to patch the policy as such,
androidmanagement.enterprises().policies().patch(
name=policy_name,
body=policy_json
).execute()
I get the following error:
<HttpError 403 when requesting https://androidmanagement.googleapis.com/v1/enterprises/XXXXXXXXX/policies/<policy_name>?alt=json returned "Caller is not authorized to manage enterprise.". Details: "Caller is not authorized to manage enterprise.">
I have verified that the service account I am authenticating with has the Android Management User role, and thus has the androidmanagement.enterprises.manage permission.
I have also attempted to make this call with an elevated admin role in the organization.
Is there a chance that I need to have created the enterprise with my own account to manage the enterprise? The guide suggests that an organization can create multiple enterprises. In which case, would I need to create a new Google account not associated with my organization's enterprise and create a new enterprise that way?
It is advisable to use your own google account to call Android Management API since your organization account may not be compatible with the quickstart.
To access the Android Management API your service account requires the androidmanagement.enterprises.manage permission, which can be granted by the Android Management User role (or roles/androidmanagement.user). Kindly check this link for details regarding creating a service account.
Please keep in mind that the enterprise you created as part of the colab instructions can only be managed using the colab itself. To allow your cloud project to manage an organization, you will need to create one using the client configuration from your cloud project.

set up MVC .NET application with Azure Connected Services

What we are trying to do is set up our MVC .NET application with Azure Connected Services within Visual Studio. We are trying to connect to the Existing Azure AD Application. We have the correct domain selected, and also the correct redirect URI
We need to be able to read directory data to determine user group but we don’t have client secret
This is the error we get
Make sure your existing Azure AD application is registered as:
Accounts in this organizational directory only (Devchat only - Single tenant) or Accounts in any organizational directory (Any Azure AD directory - Multitenant).
Other types are not supported to be updated in this case.
You can refer to this document to register an application for a quick test.

Visual Studio online insufficient privileges when creating a release definition

I'm trying to create a release definition in Visual Studio Online with the task "Deploy Azure App Service".
When I try to authorize for the subscriptions it gives this error message below.
Error(s):
Insufficient privileges to complete the operation. For troubleshooting refer to link.
The content of the link they provide doesn't seem to help me.
I already tried this using Azure Service Administrator account.
Why is this happening? What are the kind of permissions i need for doing this?
The user must be a member of Global Admin role in the directory.
On the other hand, you may configure it manually with this PowerShell script.
More information, you can refer to Automating Azure Resource Group deployment using a Service Principal in Visual Studio Online: Build/Release Management (Manual configuration section)
Download & run this PowerShell script in an Azure Powershell window to
generate required data for Service Principal based Azure service
connection. Running this script would prompt you for:
The name of your Azure Subscription name
A password that you would like to set for the Service Principal that is going to be created
Note: the script has been tested with Azure PowerShell version 1.0.2.
Once successful, the script would output the following details for the
Azure Service Endpoint.
Connection Name
Subscription Id
Subscription Name
Service Principal Client Id
Service Principal key
Tenant Id

Resources