gpt4 book ai didi

.net - 当我使用 SAML 连接到 Windows Azure Active Directory 时,始终显示 ACS75005 "The request is not a valid SAML2 protocol message."

转载 作者:行者123 更新时间:2023-12-04 10:38:04 28 4
gpt4 key购买 nike

我正在尝试在 Web 应用程序中使用 Windows Azure Active Directory 作为 IdP。我的代码在其他 SAML IdP 上运行良好,但仅在 Windows Azure AD 中给出以下消息!!

Sign in

Sorry, but we're having trouble signing you in.

We received a bad request.Additional technical information:

Trace ID:8377e605-6b9f-47be-8547-5fce7f4285af

Timestamp: 2014-08-04 13:31:27Z

ACS75005:

The request is not a valid SAML2 protocol message.

我替换了我的代码并使用了 Microsoft 发布的 SAML 请求 here并仅替换了一些值,但仍然收到相同的错误消息!!

我的请求有什么问题吗?我怎样才能获得有关该消息的更多详细信息!

知道我的应用程序是在 Windows Azure AD 应用程序中定义的。

<samlp:AuthnRequest xmlns="urn:oasis:names:tc:SAML:2.0:metadata" ID="_56dbfeac-107a-46d2-b989-651f90107312" Version="2.0" IssueInstant="2014-08-04T13:28:05Z" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">SOMETHING</Issuer>
</samlp:AuthnRequest>

编辑001按照 Dushyant 的建议编辑断言后,它变成:

<samlp:AuthnRequest xmlns="urn:oasis:names:tc:SAML:2.0:assertion" 
ID="_efcebb45-5ee6-42df-ace4-a343f28f5a46"
Version="2.0" IssueInstant="2014-08-07T06:29:09Z"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">SOMETHING</Issuer>
</samlp:AuthnRequest>

但仍然显示相同的错误!

另请找到我正在使用的测试项目here 。仅替换 Webconfig 中 AppSettings 中的值作为您的 SAML 设置。

最佳答案

使用

xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"

而不是 xmlns="urn:oasis:names:tc:SAML:2.0:metadata"

我相信您遵循了我们在这里记录的内容:http://msdn.microsoft.com/en-us/library/azure/dn195589.aspx 。如果是这样,您就发现了该文章中的错误 - 对此深表歉意。

希望这有帮助。

<小时/>

Homam,我检查了您的代码。问题在于 AuthnRequest 的编码方式。我将其更改为标准 deflate 编码并且它有效。

public string GetAzureRequest(AuthRequestFormat format)
{
string xml = @"<samlp:AuthnRequest xmlns=""urn:oasis:names:tc:SAML:2.0:assertion"" ID=""#ID""
Version=""2.0"" IssueInstant=""#DATE""
xmlns:samlp=""urn:oasis:names:tc:SAML:2.0:protocol"">
<Issuer xmlns=""urn:oasis:names:tc:SAML:2.0:assertion"">#ISSUER</Issuer>
</samlp:AuthnRequest>";

xml = xml.Replace("#DATE", issue_instant);
xml = xml.Replace("#ID", id);
xml = xml.Replace("#ISSUER", appSettings.Issuer);
xml = xml.Replace("\r\n", "");

if (format == AuthRequestFormat.Base64)
{
/*COMMENTED THIS OUT*/

//byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(requestDocument.OuterXml);
//string result = System.Convert.ToBase64String(toEncodeAsBytes);
//return result;


/*ADDED THIS*/

MemoryStream memoryStream = new MemoryStream();
StreamWriter writer = new StreamWriter(new DeflateStream(memoryStream, CompressionMode.Compress, true), new UTF8Encoding(false));
writer.Write(xml);
writer.Close();
string result = Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length, Base64FormattingOptions.None);
return result;
}

return null;
}

关于.net - 当我使用 SAML 连接到 Windows Azure Active Directory 时,始终显示 ACS75005 "The request is not a valid SAML2 protocol message.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25120025/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com