【问题标题】:"Add-AzureAccount" Got an error: Returned by service does not match user 'XXX' in the request“Add-AzureAccount”出现错误:服务返回的请求与请求中的用户“XXX”不匹配
【发布时间】:2019-07-01 06:49:17
【问题描述】:

在 PowerShell 中运行“Add-AzureAccount”命令时出现错误: 服务返回的与请求中的用户“XXX”不匹配。

步骤: 打开 PowerShell=>输入“Add-AzureAccount”=>Microsoft 登录 UI 弹出=>输入我的 AD 电子邮件 =>重定向到我的公司身份验证页面 (ADFS)=>输入我的密码=> 显示错误

Add-AzureAccount : User 'xxx@carrier.utc.com' returned by service does not match user 'xxxxxx@UTCCGL.com' in the request

At line:1 char:1
+ Add-AzureAccount
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

Debug Log


DEBUG: 11:38:52 - AddAzureAccount begin processing with ParameterSet 'User'.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'Common', Endpoint: 'https://login.microsoftonline.
com/', ClientId: '**XXXXX**', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://mana
gement.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/Common/', CorrelationI
d: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'Common', AdEndpoint: 'https://login.microsoftonl
ine.com/', ClientId: 'XXXXXX', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:38:57: 901cc9d7-c601-4f0b-9558-6a83b7ceddf5 - AcquireTokenHandlerBase: === Token Acquisition started:
    Authority: https://login.microsoftonline.com/Common/
    Resource: https://management.core.windows.net/
    ClientId: XXXXX
    CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
    Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:38:57:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/Common/oauth2
/authorize?resource=https://management.core.windows.net/&client_id=XXXXX&response_type=code&haschrome=1
&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=XXXXX&prompt=login&x-client-SKU=.NET&x-client
-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.16299.0&site_id=501358&display=popup'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:38:57:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/Common/oauth2
/authorize?resource=https://management.core.windows.net/&client_id=XXXXX&response_type=code&haschrome=1
&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=XXXXX&prompt=login&x-client-SKU=.NET&x-client
-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.16299.0&site_id=501358&display=popup&sso_nonce=AQABAAAAAADCoMpj
JXrxTq9VG9te-7FX-DwzfR6rI_XrfZdXD670F6R5VHRu4Ff-09tO6L2hWujlpsWpl8LnubUat_G1yfX59vZx3UoEDDnq7HMPvfVjViAA&mscrid=901cc9d7-c601-4f0b-955
8-6a83b7ceddf5'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:38:58:  - WindowsFormsWebAuthenticationDialogBase: Navigated to 'https://login.microsoftonline.com/Common/oauth2/
authorize?resource=https://management.core.windows.net/&client_id=XXXXX&response_type=code&haschrome=1&
redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=XXXXX&prompt=login&x-client-SKU=.NET&x-client-
Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.16299.0&site_id=501358&display=popup&sso_nonce=AQABAAAAAADCoMpjJ
XrxTq9VG9te-7FX-DwzfR6rI_XrfZdXD670F6R5VHRu4Ff-09tO6L2hWujlpsWpl8LnubUat_G1yfX59vZx3UoEDDnq7HMPvfVjViAA&mscrid=901cc9d7-c601-4f0b-9558
-6a83b7ceddf5'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:38:58:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.live.com/Me.htm?v=1'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:38:58:  - WindowsFormsWebAuthenticationDialogBase: Navigated to 'https://login.live.com/Me.htm?v=1'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:39:11:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth
=http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
&username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiM
tIzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlV
makmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz8
24wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfX
OTM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc='.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:39:13:  - WindowsFormsWebAuthenticationDialogBase: Navigated to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth=
http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiMt
IzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlVm
akmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz82
4wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfXO
TM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc='.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:27:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth
=http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
&username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiM
tIzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlV
makmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz8
24wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfX
OTM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc='.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:29:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth
=http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
&username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiM
tIzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlV
makmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz8
24wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfX
OTM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc='.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:31:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth
=http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
&username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiM
tIzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlV
makmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz8
24wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfX
OTM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc=&ssoCookie=0d5c1e40-8d5b
-46eb-854e-e14c815542f5'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:32:  - WindowsFormsWebAuthenticationDialogBase: Navigated to 'https://fsaz.utcapp.com/adfs/ls/?wfresh=0&wauth=
http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password&client-request-id=XXXXX
username=XXX@utccgl.com&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=LoginOptions=3&estsredirect=2&estsrequest=rQIIAePiMt
IzstAz1rMwMxBiNNRiNtQztFIxtDQ1SDQytdA1MjJP0jVJNTbUTbRMTtM1NzQ3sTS1NDFNSzbyYjM1MDQ2tSgS4hK4flJmAuMxbv-pEVnN28_d_TqJkbUgv6C0YBWjZGlRnlVm
akmaVXm6VX5iaUmGlZGegVV-ftIORsYLjIwvGBlvMfH7OwIljEBEflFmVeorJtac_PTMvFXMKhklJQXFVvr6uYl5iempual5JXrJ-UWpeuWZeSn55cV6eakl-puY2ZLzc3Pz82
4wMz5i5isvrXAoLUlOTs8BKs29wML4ikWCg0lARoJZ4Q6bBosBsxUnB5cAg8TqegWGHyyMi1iBHuBYIbd7J9sL5xUdGz2qD0YwnGLVL09JDUgKTknMz6xMs6zQTsoIjSpMDfXO
TM01TsoJcvfwKi_11jd19_TTdrQ1tTKcwMZ4io1Fz8815AMbYwc7wy5O3F6_xSViZGBoqWtgrmtgpGBgbGVsaWVgEQUA0&cbcxt=&mkt=&lc=&ssoCookie=0d5c1e40-8d5b-
46eb-854e-e14c815542f5'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:32:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/login.srf?cli
ent-request-id=XXXXX'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:33:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state: IsBusy: True, ReadyState: Complete, Created:
 True, Disposing: False, IsDisposed: False, IsOffline: False

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:33:  - WindowsFormsWebAuthenticationDialogBase: WebBrowser state (after Stop): IsBusy: False, ReadyState: Comp
lete, Created: True, Disposing: False, IsDisposed: False, IsOffline: False

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:34: XXXXX - TokenCache: Storing token in the cache...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:34: XXXXX - TokenCache: An item was stored in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:41:34: XXXXX - AcquireTokenHandlerBase: === Token Acquisition finished successfull
y. An access token was retuned:
    Access Token Hash: XXXXX
    Refresh Token Hash: U80lp4/LTmBKc3Xh5hYpWpdfaTe2hbxSxvtD4PDMVqk=
    Expiration Time: 07/02/2019 04:41:34 +00:00
    User Hash: XXXXX


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:41:34:  - TokenCache: Serializing token cache with 1 items.

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.core.windows.net/subscriptions

Headers:
x-ms-version                  : 2013-08-01

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
x-ms-servedbyregion           : ussouth3
x-ms-request-id               : d1d99bf68fc0aa77953c90dc85c56894
Cache-Control                 : no-cache
Date                          : Tue, 02 Jul 2019 03:41:35 GMT
Server                        : 67.3.0.175/release1,(c937119),Microsoft-HTTPAPI/2.0

Body:
<Subscriptions xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Subscription>
    <SubscriptionID>XXXX</SubscriptionID>
    <SubscriptionName>XXXX</SubscriptionName>
    <SubscriptionStatus>Active</SubscriptionStatus>
    <AccountAdminLiveEmailId>XXXXX@outlook.com</AccountAdminLiveEmailId>
    <ServiceAdminLiveEmailId>XXXXX@outlook.com</ServiceAdminLiveEmailId>
    <MaxCoreCount>350</MaxCoreCount>
    <MaxStorageAccounts>100</MaxStorageAccounts>
    <MaxHostedServices>20</MaxHostedServices>
    <CurrentCoreCount>0</CurrentCoreCount>
    <CurrentHostedServices>0</CurrentHostedServices>
    <CurrentStorageAccounts>0</CurrentStorageAccounts>
    <MaxVirtualNetworkSites>100</MaxVirtualNetworkSites>
    <MaxLocalNetworkSites>20</MaxLocalNetworkSites>
    <MaxDnsServers>20</MaxDnsServers>
    <OfferCategories>Azure_Platform_All;Azure_Paid;Azure_Consumption;Azure_EA;Azure_MS-AZR-0017P;Individual</OfferCategories>
    <MaxExtraVIPCount>-1</MaxExtraVIPCount>
    <AADTenantID>XXXXX</AADTenantID>
    <CreatedTime>2018-09-27T06:41:39Z</CreatedTime>
  </Subscription>
  <Subscription>
    <SubscriptionID>XXXXX</SubscriptionID>
    <SubscriptionName>XXX</SubscriptionName>
    <SubscriptionStatus>Active</SubscriptionStatus>
    <AccountAdminLiveEmailId>XXXX@outlook.com</AccountAdminLiveEmailId>
    <ServiceAdminLiveEmailId>XXXXX@outlook.com</ServiceAdminLiveEmailId>
    <MaxCoreCount>350</MaxCoreCount>
    <MaxStorageAccounts>100</MaxStorageAccounts>
    <MaxHostedServices>20</MaxHostedServices>
    <CurrentCoreCount>0</CurrentCoreCount>
    <CurrentHostedServices>0</CurrentHostedServices>
    <CurrentStorageAccounts>0</CurrentStorageAccounts>
    <MaxVirtualNetworkSites>100</MaxVirtualNetworkSites>
    <MaxLocalNetworkSites>20</MaxLocalNetworkSites>
    <MaxDnsServers>20</MaxDnsServers>
    <OfferCategories>Azure_Platform_All;Azure_Paid;Azure_Consumption;Azure_EA;Azure_MS-AZR-0017P;Individual</OfferCategories>
    <MaxExtraVIPCount>-1</MaxExtraVIPCount>
    <AADTenantID>XXXXX</AADTenantID>
    <CreatedTime>2018-11-12T01:32:21Z</CreatedTime>
  </Subscription>
  <Subscription>
    <SubscriptionID>XXXXX</SubscriptionID>
    <SubscriptionName>XXXX</SubscriptionName>
    <SubscriptionStatus>Active</SubscriptionStatus>
    <AccountAdminLiveEmailId>XXXX@outlook.com</AccountAdminLiveEmailId>
    <ServiceAdminLiveEmailId>XXXX@outlook.com</ServiceAdminLiveEmailId>
    <MaxCoreCount>350</MaxCoreCount>
    <MaxStorageAccounts>100</MaxStorageAccounts>
    <MaxHostedServices>20</MaxHostedServices>
    <CurrentCoreCount>0</CurrentCoreCount>
    <CurrentHostedServices>0</CurrentHostedServices>
    <CurrentStorageAccounts>0</CurrentStorageAccounts>
    <MaxVirtualNetworkSites>100</MaxVirtualNetworkSites>
    <MaxLocalNetworkSites>20</MaxLocalNetworkSites>
    <MaxDnsServers>20</MaxDnsServers>
    <OfferCategories>Azure_Platform_All;Azure_Paid;Azure_Consumption;Azure_EA;Azure_MS-AZR-0017P;Individual</OfferCategories>
    <MaxExtraVIPCount>-1</MaxExtraVIPCount>
    <AADTenantID>XXXXX</AADTenantID>
    <CreatedTime>2018-08-28T02:42:13Z</CreatedTime>
  </Subscription>
  <Subscription>
    <SubscriptionID>XXXX</SubscriptionID>
    <SubscriptionName>XXXXX</SubscriptionName>
    <SubscriptionStatus>Active</SubscriptionStatus>
    <AccountAdminLiveEmailId>XXX@UTCCGL.com</AccountAdminLiveEmailId>
    <ServiceAdminLiveEmailId>XXX@UTCCGL.com</ServiceAdminLiveEmailId>
    <MaxCoreCount>350</MaxCoreCount>
    <MaxStorageAccounts>100</MaxStorageAccounts>
    <MaxHostedServices>20</MaxHostedServices>
    <CurrentCoreCount>0</CurrentCoreCount>
    <CurrentHostedServices>0</CurrentHostedServices>
    <CurrentStorageAccounts>0</CurrentStorageAccounts>
    <MaxVirtualNetworkSites>100</MaxVirtualNetworkSites>
    <MaxLocalNetworkSites>20</MaxLocalNetworkSites>
    <MaxDnsServers>20</MaxDnsServers>
    <OfferCategories>Azure_Platform_All;Azure_Paid;Azure_Consumption;Azure_EA;Azure_MS-AZR-0017P;Individual</OfferCategories>
    <MaxExtraVIPCount>-1</MaxExtraVIPCount>
    <AADTenantID>XXXXXXXXX</AADTenantID>
    <CreatedTime>2019-05-13T02:58:34Z</CreatedTime>
  </Subscription>
</Subscriptions>


DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'XXXXX', Endpoint: '
https://login.microsoftonline.com/', ClientId: 'XXXX', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', Re
sourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/f4841380-e7f4-4f8b-9d3
f-525914ae311d/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'f4841380-e7f4-4f8b-9d3f-525914ae311d', AdEndpoin
t: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oo
b
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:41:36: ddba4a62-c19a-462d-bdda-174ad69a7b7a - AcquireTokenHandlerBase: === Token Acquisition started:
    Authority: https://login.microsoftonline.com/f4841380-e7f4-4f8b-9d3f-525914ae311d/
    Resource: https://management.core.windows.net/
    ClientId: XXXXX
    CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
    Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:36: XXXX - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:41:36: XXXXX - TokenCache: No matching token was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:36:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/f4841380-e7f4
-4f8b-9d3f-525914ae311d/oauth2/authorize?resource=https://management.core.windows.net/&client_id=XXXX
response_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&login_hint=WUX@UTCCGL.com&client-request-id=XXXXX&prompt=attempt_none&x-client-SKU=.NET&x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.
16299.0&site_id=501358&display=popup'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/02/2019 03:41:37:  - WindowsFormsWebAuthenticationDialogBase: Navigating to 'https://login.microsoftonline.com/XXXX/oauth2/authorize?resource=https://management.core.windows.net/&client_id=XXXXX
response_type=code&haschrome=1&redirect_uri=urn:ietf:wg:oauth:2.0:oob&login_hint=XXX@UTCCGL.com&client-request-id=XXXXX&prompt=attempt_none&x-client-SKU=.NET&x-client-Ver=2.28.3.860&x-client-CPU=x64&x-client-OS=Microsoft Windows NT 10.0.
16299.0&site_id=501358&display=popup&sso_nonce=AQABAAAAAADCoMpjJXrxTq9VG9te-7FXACiy4PAt-bgXL2BHSIuPj0VUe1VyjXdxXb8cpsLvAGzOmy1o8kJ0QfZ
OH1zopd9MgnCPQkOVELD4N_ndC8w4vCAA&mscrid=ddba4a62-c19a-462d-bdda-174ad69a7b7a'.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Error: 4 : 
DEBUG: 07/02/2019 03:41:39:XXXXX - <RunAsync>d__0: Microsoft.IdentityModel.Clients.ActiveDirectory.Ada
lUserMismatchException: User 'XXXXX@carrier.utc.com' returned by service does not match user 'XXX@UTCCGL.com' in the request
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenInteractiveHandler.PostTokenRequest(AuthenticationResult result)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__0.MoveNext()
    ErrorCode: user_mismatch
    RequestedUser: XXX@UTCCGL.com
    ReturnedUser: XXXXX@carrier.utc.com

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/02/2019 03:41:39:  - TokenCache: Serializing token cache with 1 items.

Add-AzureAccount : User 'XXXXX@carrier.utc.com' returned by service does not match user 'XXX@UTCCGL.com' in the request
At line:1 char:1
+ Add-AzureAccount -Debug
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

DEBUG: AzureQoSEvent: CommandName - Add-AzureAccount; IsSuccess - False; Duration - 00:02:50.2749847; Exception - Microsoft.Azure.Comm
ands.Common.Authentication.AadAuthenticationFailedException: User 'XXXXX@carrier.utc.com' returned by service does not match user 'XX
X@UTCCGL.com' in the request ---> Microsoft.IdentityModel.Clients.ActiveDirectory.AdalUserMismatchException: User 'XXXXX@carrier.utc.
com' returned by service does not match user 'XXX@UTCCGL.com' in the request
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask[T](Task`1 task)
   at Microsoft.Azure.Commands.Common.Authentication.UserTokenProvider.DoAcquireToken(AdalConfiguration config, PromptBehavior promptB
ehavior, Action`1 promptAction, String userId, SecureString password)
   at Microsoft.Azure.Commands.Common.Authentication.UserTokenProvider.SafeAquireToken(AdalConfiguration config, String showDialog, Ac
tion`1 promptAction, String userId, SecureString password, Exception& ex)
   --- End of inner exception stack trace ---
   at Microsoft.Azure.ServiceManagemenet.Common.ProfileClient.WriteOrThrowAadExceptionMessage(AadAuthenticationException aadEx)
   at Microsoft.Azure.ServiceManagemenet.Common.ProfileClient.ListSubscriptionsFromServer(IAzureAccount account, IAzureEnvironment env
ironment, SecureString password, String promptBehavior, Action`1 promptAction)
   at Microsoft.Azure.ServiceManagemenet.Common.ProfileClient.AddAccountAndLoadSubscriptions(IAzureAccount account, IAzureEnvironment 
environment, SecureString password)
   at Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 11:41:43 - AddAzureAccount end processing.
DEBUG: 11:41:43 - AddAzureAccount end processing.

【问题讨论】:

  • 我认为您的广告 upn 与您用于登录的 upn 不匹配。请尝试使用此广告登录:xxxxxx@UTCCGL.com?
  • 尝试运行Clear-AzureProfile,然后再次运行Add-AzureAccount。
  • @4c74356b41 谢谢,我试过了,还是一样的错误。我怀疑我的域名 (xxx.carrier.utc.com) 和 AAD 帐户 (xxxxxx@UTCCGL.com) 有问题。但我根本不知道出了什么问题。
  • @Joy Wang 谢谢,试过了,不行。
  • 也可以试试Get-AzureAccount | Remove-AzureAccount,然后Add-AzureAccount,类似的问题:answers.flyppdevportal.com/MVC/Post/Thread/…

标签: azure active-directory azure-active-directory adfs azure-powershell


【解决方案1】:

尝试使用 powershell 版本 5.1.14393.1198 重现相同的问题并且能够重现它。

我能够通过首先使用 Remove-AzureAccount 删除帐户,然后再次添加帐户并使用“**Add-AzureAccount**”命令选择个人帐户来解决。

请尝试看看是否有帮助。如果仍然不起作用,请告诉我并提供详细的详细日志,将能够为您提供进一步的帮助。

【讨论】:

  • 不工作。我添加了调试信息。我认为解决问题就足够了。
【解决方案2】:

您必须手动删除您的配置文件(Clear-AzureProfile 也会失败)。 Remove-Item "$env:USERPROFILE\AppData\Roaming\Windows Azure Powershell"

注意:系统需要重新启动才能进行必要的更改

请使用命令“$PSVersionTable.PSVersion”检查 PS 如果不是 5.1,请按照文档https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6 中的步骤进行更新 选择 WFM 5.1 然后 .Net 框架也必须更新到 .NET Framework 4.7.2 版本 https://dotnet.microsoft.com/download/dotnet-framework-runtime 安装 PS 后,再次继续安装模块 安装模块 -Name Az -AllowClobber 默认情况下,PowerShell 库未配置为 PowerShellGet 的受信任存储库。首次使用 PSGallery 时,您会看到以下提示: @Mohit verma 建议再次添加帐户

【讨论】:

    猜你喜欢
    • 2020-12-01
    • 1970-01-01
    • 2018-07-18
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    相关资源
    最近更新 更多