0
我无法使用NTLM从C#与Teamcity进行身份验证。它适用于浏览器和邮递员。C#到TeamCity NTLM身份验证失败
随着日志功能似乎做NTLM握手,但随后在401错误与结算:
The token supplied to the function is invalid
To login manually go to "/login.html" page
示例代码如下。我不确定这里有什么问题。它适用于基本身份验证和包含httpAuth的修改后的URI。
string uri = "http://teamcityserver/ntlmAuth/action.html?add2Queue=SomeBuild";
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(uri), "NTLM", new NetworkCredential("user", "password")); // Have also tried default credentials
var req = HttpWebRequest.Create(uri);
req.Method = "POST";
req.Credentials = cc;
req.Headers.Add("Origin: http://teamcity");
AFAIK与Windows帐户打交道时,你必须包括域名(或缺乏一个域,本地计算机名称)作为用户名的一部分,例如'域\ user'。 – NightOwl888
@ NightOwl888 NetworkCredential有3个参数版本,作为第三个参数,我也尝试过没有成功。为了以防万一,我将它添加到用户字段中,但获得了相同的结果。 –