Tag: defaultnetworkcredentials

如何在没有用户密码的情况下获取Alfresco登录票证,但使用用户主体名称(UPN)模拟用户

我正在编写一个DLL,它具有在不使用用户密码的情况下获取Alfresco登录票证的function,仅使用用户主体名称(UPN)。 我正在调用alfresco REST API服务/ wcservice 。 我在Alfresco使用NTLM。 我正在冒充使用WindowsIdentity构造函数的用户,如http://msdn.microsoft.com/en-us/library/ms998351.aspx#paght000023_impersonatingbyusingwindowsidentity所述 。 我检查并且用户被正确模拟(我检查了WindowsIdentity.GetCurrent().Name属性)。 在模仿用户之后,我尝试使用CredentialsCache.DefaultNetworkCredentials制作HttpWebRequest并设置其凭据。 我收到错误: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() 当我使用new NetworkCredential(“username”, “P@ssw0rd”)来设置请求凭据时,我获得了Alfresco登录票证( HttpStatusCode.OK ,200)。 有没有办法可以在没有用户密码的情况下获得Alfresco登录票? 这是我正在使用的代码: private string GetTicket(string UPN) { WindowsIdentity identity = new WindowsIdentity(UPN); WindowsImpersonationContext context = null; try { context = identity.Impersonate(); MakeWebRequest(); } catch (Exception e) { return […]

WebClient访问具有凭据的页面

我正在尝试访问同一个域/同一个asp.net应用程序的网页,这是受密码保护的。 对于发起此呼叫的网页和正在访问的网页,凭据都是相同的。 这是代码,我不知道为什么我总是以登录表单html代码结束? using (WebClient client = new WebClient()) { client.QueryString.Add(“ID”, “1040”); //add parameters //client.Credentials = CredentialCache.DefaultCredentials; //I tried to add credentials like this client.Credentials = new NetworkCredential(“username”, “password”); string htmlCode = client.DownloadString(“http://domain.loc/testpage.aspx”); }