- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Azure AD PS 模块的新预览版本。我正在尝试通过新的 AccessToken 参数进行连接:
Connect-MsolService - AccessToken ey...
但我收到了“意外错误”。
Connect-MsolService : An unexpected error occurred.
At line:1 char:1
+ Connect-MsolService -AccessToken eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidHeaderException,Microsoft.Online.Admin
istration.Automation.ConnectMsolService
Connect-MsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was
thrown.
At line:1 char:1
+ Connect-MsolService -AccessToken eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Adm
inistration.Automation.ConnectMsolService
我知道我使用的访问 token 很好,因为我可以使用它从 Postman 调用 Graph API。有人让它工作吗?
编辑:不确定否决的原因,但只是为了表明我做了我的功课,这里是 PS 模块在幕后发出的请求/响应,用 Fiddler 跟踪捕获。它包含有用的消息“用户身份 header 无效。”
请求
POST https://provisioningapi.microsoftonline.com/provisioningwebservice.svc HTTP/1.1
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://provisioning.microsoftonline.com/IProvisioningWebService/MsolConnect</a:Action>
<a:MessageID>urn:uuid:df0e35bd-ef05-48cd-a623-a1134b0b2ed6</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<UserIdentityHeader xmlns="http://provisioning.microsoftonline.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<BearerToken xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService">Bearer ey...</BearerToken>
<LiveToken i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService"/>
</UserIdentityHeader>
<ClientVersionHeader xmlns="http://provisioning.microsoftonline.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ClientId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService">50afce61-c917-435b-8c6d-60aa5a8b8aa7</ClientId>
<Version xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService">1.1.8806.11</Version>
</ClientVersionHeader>
<ContractVersionHeader xmlns="http://becwebservice.microsoftonline.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<BecVersion xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService">Version32</BecVersion>
</ContractVersionHeader>
<TrackingHeader xmlns="http://becwebservice.microsoftonline.com/">bf71f0c6-add7-4046-9209-bfd584ca3c28</TrackingHeader>
<a:To s:mustUnderstand="1">https://provisioningapi.microsoftonline.com/provisioningwebservice.svc</a:To>
</s:Header>
<s:Body>
<MsolConnect xmlns="http://provisioning.microsoftonline.com/">
<request xmlns:b="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:BecVersion>Version4</b:BecVersion>
<b:TenantId i:nil="true"/>
<b:VerifiedDomain i:nil="true"/>
</request>
</MsolConnect>
</s:Body>
</s:Envelope>
回应
HTTP/1.1 500 Internal Server Error
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://provisioning.microsoftonline.com/IProvisioningWebService/MsolConnectInvalidHeaderExceptionFault</a:Action>
<a:RelatesTo>urn:uuid:df0e35bd-ef05-48cd-a623-a1134b0b2ed6</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">The creator of this fault did not specify a Reason.</s:Text>
</s:Reason>
<s:Detail>
<InvalidHeaderException xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Online.Administration.WebService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<Message>The user identity header is invalid.</Message>
<OperationId i:nil="true"/>
<Source>Microsoft.Online.Administration.PublicBecWebService</Source>
<StackTrace> at Microsoft.Online.Administration.WebService.BecWebServiceAuthenticationManager.ValidateJwtTokenV2(String bearerToken) in x:\bt\533229\repo\src\dev\om\administration\publicbecwebservice\BecWebServiceAuthenticationManager.cs:line 371
at Microsoft.Online.Administration.WebService.BecWebServiceAuthenticationManager.CheckAccessCore(OperationContext operationContext) in x:\bt\533229\repo\src\dev\om\administration\publicbecwebservice\BecWebServiceAuthenticationManager.cs:line 723</StackTrace>
</InvalidHeaderException>
</s:Detail>
</s:Fault>
</s:Body>
</s:Envelope>
以下是我获取访问 token 的方法。我正在使用客户端凭据流程,因为我的最终目标是从 Azure 自动化运行此流程。
$clientId = "20bc779d-0edb-4a00-becf-xxx"
$redirectUri = new-object System.Uri("urn:ietf:wg:oauth:2.0:oob")
$resourceId = "https://graph.windows.net"
$authority = "https://login.windows.net/mydirectory.onmicrosoft.com"
$key = ConvertTo-SecureString $keyFromAzurePortal -AsPlainText -Force
$cred = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential ($clientId, $key)
$authContext = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext($authority)
$authResult = $authContext.AcquireToken($resourceId, $cred)
最佳答案
我无法重现您的问题。让我告诉你我做了什么来让它工作:
我首先获得了针对 Graph API 的 native 客户端应用程序的访问 token :
$clientId = "<GUID>";
$tenantId = "<tenant>.onmicrosoft.com";
$resourceId = "https://graph.windows.net"
$redirectUri = new-object System.Uri("urn:ietf:wg:oauth:2.0:oob")
$login = "https://login.microsoftonline.com"
$authContext = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext("{0}/{1}" -f $login,$tenantId);
$authenticationResult = $authContext.AcquireToken($resourceId,$clientID,$redirectUri);
$token = $authenticationResult.AccessToken
然后我在 PowerShell 中使用了该 token :
PS C:\Users\shtabriz> Connect-MsolService -AccessToken eyJ0eXAiOiJKV1QiLCJ...
PS C:\Users\shtabriz> Get-MsolUser
UserPrincipalName DisplayName isLicensed
----------------- ----------- ----------
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e99d8c9a9da99a81889e879d8c9a9dc7868784808a9b869a868f9dc78a8684" rel="noreferrer noopener nofollow">[email protected]</a> TestMe False
shtabriz_microsoft.com#EXT#@shawntest.onmicrosoft.com Shawn Tabrizi False
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a3b3e3733341a29323b2d342e3f292e743534373339283529353c2e74393537" rel="noreferrer noopener nofollow">[email protected]</a> ShawnTabriziAdmin False
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="450429203d05362d24322b312036316b2a2b282c26372a362a23316b262a28" rel="noreferrer noopener nofollow">[email protected]</a> Alex Wu False
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ae6ebe4edffebedefcaf9e2ebfde4feeff9fea4e5e4e7e3e9f8e5f9e5ecfea4e9e5e7" rel="noreferrer noopener nofollow">[email protected]</a> Language False
languageportal@shawntest.onmicrosoft.com Language Portal False
您获得哪种访问 token ?你介意分享一下吗?或者至少是没有签名的 JWT 反编译版本?
如果您想将此内容带到其他地方,请随时通过以下方式与我们联系
请包含此处找到的日志文件:
C:\Users[youralias]\AppData\Local\Microsoft\Office365\Powershell
关于powershell - "Unexpected Error"使用 Connect-MsolService -AccessToken 连接到 Azure AD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33114254/
似乎有很多方法可以在 Azure 中自动使用 PowerShell。由于 ARM 模板是最新的,Azure 中的其他 PowerShell 选项是否已过时?这些工具/脚本之间有什么区别: Azure
我正在开发一个将托管在 Azure 中的 Web API。我想使用 Azure 诊断将错误记录到 Azure 表存储中。在经典门户中,我可以将日志配置为转到 Azure 表存储。 Classic Po
Azure 文件存储事件可以触发 Azure WebJob 或 Azure Function 吗? 例如,在文件夹“/todo/”中创建文件时。 最佳答案 我们目前没有任何 Azure 文件绑定(bi
我需要创建一个逻辑应用程序,我的要求是,我需要从 azure data Lake Gen2 文件夹迁移 json 文件,并根据某些值需要将该 json 转换为 xml,然后将其发送到 SQL。 因此,
我使用 VS Code 创建了 1 个 node.js 和 1 个 java Azure Function 当我使用 VS Code 将这两个函数部署到 Azure 时,我最终获得了这么多 Azure
收集 Azure 诊断数据时,暂存槽是否也会将诊断数据发送到 WadPerformanceCounters 表? 如果是这样,我该如何关闭它?或者在阅读诊断信息时如何区分暂存/生产。 我不想显示有关我
您好,我是 Azure 的新手。我有 VS 2012 和 Azure SDK 2.1,当我使用模拟器运行我的 Web 应用程序时一切正常。但是当我在 azure 上部署时出现错误消息: Could n
我很难区分 Azure 订阅和 Azure 租户有何不同?我尝试使用示例来弄清楚,但每次我得出的结论是它们在某种程度上是相同的?如果租户是组织在注册 Microsoft 云服务时接收并拥有的 Azur
如果我想在 Azure Insights 中设置自定义指标集合,并以(近)实时的方式可视化其中一些指标,并查看聚合的历史数据,我应该使用 Azure Metrics Explorer 还是 Azure
我想了解具有以下配置的 Azure 数据工厂 (ADF) 的现实示例/用例: Azure 集成运行时 (AIR) 默认值 自托管集成运行时(SHIR) 其他问题: 这两种配置(AIR 和 SHIR)是
请参阅下面来自 Azure 服务总线的指标。想要识别请求数量中的背景噪音|流量较低时的响应。假设振荡请求| session 中 amqp 握手的响应是潜在的。只是不明白这是什么类型的握手?从总线接收的
此问题与 Azure 事件中心和 Azure 服务总线之间的区别无关。 问题如下: 如果您将Azure Events Hub添加到您的应用程序中,那么您会注意到它依赖于Azure Service Bu
这两个事情是完全不同的,还是它们能完成的事情大致相同/相似? 最佳答案 Azure 辅助角色是“应用程序场”中您自己的一组虚拟机。您可以以分布式方式在它们上运行任何代码。通常,您编写业务代码以在这些服
我目前正在使用 Windows Azure 虚拟机来运行 RStudio, 我的虚拟机是 Windows Server R2 2012,它是 Azure 上的一项附加服务。 我还有一个 Azure 存
我们正在寻找托管一个网站(一些 css、js、一个 html 文件,但不是 aspx、一个通用处理程序)。 我们部署为: 1) Azure 网站 2) Azure 云服务 两种解决方案都有效。但有一个
我想从 Azure 表创建 blob。 AzCopy 支持此功能,但我找不到任何说明数据移动 API 也支持它的文档。此选项可用吗? https://azure.microsoft.com/en-us
This article表示 Azure 订阅所有者有权访问订阅中的所有资源。但是,要访问 Azure 数据库,必须是数据库中的用户,或者是 Azure Admin AD 组的成员。 无论 SQL 安
我尝试使用以下代码将 XML 文件上传到 Azure FTP 服务器: https://www.c-sharpcorner.com/article/upload-and-download-files-
除了 Azure 服务总线使用主题而 Azure 事件中心基于事件 - Azure 事件中心和 Azure 服务总线之间是否有任何根本区别? 对我来说,事件和消息之间没有真正的区别,因为两者只是不同类
我有一个通过虚拟网络网关连接到 Azure 虚拟网络的 Windows VPN 客户端。目标#1 是使用其内部 IP 地址连接到我的虚拟机。这有效。 第二个目标是使用其内部计算机名称进行连接(因为 I
我是一名优秀的程序员,十分优秀!