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個參數版本,作爲第三個參數,我也嘗試過沒有成功。爲了以防萬一,我將它添加到用戶字段中,但獲得了相同的結果。 –