c# – SharePoint Online身份验证失败

c# – SharePoint Online身份验证失败,第1张

概述我有一个C#应用程序,它使用Web请求对SharePoint Online进行身份验证.它适用于我,但其他人收到以下错误: <?xml version="1.0" encoding="utf-8" ?><S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.or 我有一个C#应用程序,它使用Web请求对SharePoint Online进行身份验证.它适用于我,但其他人收到以下错误:

<?xml version="1.0" enCoding="utf-8" ?><S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault">  <S:Body>    <S:Fault>      <S:Code>        <S:Value>S:Sender</S:Value>        <S:Subcode>          <S:Value>wst:FailedAuthentication</S:Value>        </S:Subcode>      </S:Code>      <S:Reason>        <S:Text xml:lang="en-US">Authentication Failure</S:Text>      </S:Reason>      <S:Detail>        <psf:error>          <psf:value>0x80048821</psf:value>          <psf:internalerror>            <psf:code>0x80041034</psf:code>            <psf:text>The specifIEd member name is either invalID or empty.&#x000D;&#x000A;</psf:text>          </psf:internalerror>        </psf:error>      </S:Detail>    </S:Fault>  </S:Body></S:Envelope>

这个错误是什么意思?我很确定他们输入了正确的用户名和密码.是否有一个SharePoint Online错误代码列表,我可以找到哪些地方可以帮助我识别问题?

这是我的C#代码:

var request = (httpWebRequest)WebRequest.Create(@"https://login.microsoftonline.com/extSTS.srf");request.AllowautoRedirect = false;request.ContentType = @"application/Json; odata=verbose";request.cookieContainer = this.cookieContainer;request.Method = @"POST";request.UserAgent = @"Mozilla/5.0 (compatible; MSIE 9.0; windows NT 6.1; WOW64; TrIDent/5.0)";string soapRequest = Strings.SharePointOnlineAuthenticationRequest    .Replace(@"$(Username)",this.Username)    .Replace(@"$(Password)",this.Password)    .Replace(@"$(Address)",this.SiteUrl);byte[] contentBytes = new ASCIIEnCoding().GetBytes(soapRequest);request.ContentLength = contentBytes.Length;using (var requestStream = request.GetRequestStream()){    requestStream.Write(contentBytes,contentBytes.Length);}

Strings.SharePointOnlineAuthenticationRequest

这是我发送的SOAP请求. “$(Username)”,“$(密码)”和“$(地址)”标记在运行时被替换.

<value>  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  <s:header>  <a:Action s:mustUnderstand="1=">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>  <a:ReplyTo>  <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>  </a:ReplyTo>  <a:To s:mustUnderstand="1=">https://login.microsoftonline.com/extSTS.srf</a:To>  <o:Security s:mustUnderstand="1=" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">  <o:UsernameToken>  <o:Username>$(Username)</o:Username>  <o:Password>$(Password)</o:Password>  </o:UsernameToken>  </o:Security>  </s:header>  <s:Body>  <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">  <wsp:ApplIEsTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">  <a:EndpointReference>  <a:Address>$(Address)</a:Address>  </a:EndpointReference>  </wsp:ApplIEsTo>  <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/IDentity/noproofKey</t:KeyType>  <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>  <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>  </t:RequestSecurityToken>  </s:Body>  </s:Envelope></value>
解决方法 最近是否更改了用户名,我发现名称更改后缺少ADFS声明的问题: see techet article AD FS 2.0: Claims Are Missing From The Output Claim Set After A User’s Name Has Changed 总结

以上是内存溢出为你收集整理的c# – SharePoint Online身份验证失败全部内容,希望文章能够帮你解决c# – SharePoint Online身份验证失败所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1226719.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存