将AD身份验证凭据传递到C#Windows窗体中的IE浏览器

时间:2009-01-19 07:33:28

标签: winforms

我有一个Sharepoint站点,我想通过使用C#Windows应用程序在IE中打开此站点。我在IE中成功打开了网站,但我的问题是如何将UserCredentials发送到网站。它使用defalut凭据在IE中打开网站。 我的defalut凭据是用户名:systemaccount密码= 123 但我想在IE中用一些不同的凭据打开Sharepoint网站,例如用户名:abc密码:123(我有“abc”作为AD和Sharepoint用户)

这是我在IE中打开Sharepoint网站的代码

SecureString sec = new SecureString();
             sec.AppendChar('1');
             sec.AppendChar('2');
             sec.AppendChar('3');

Process.Start("IEXPLORE.EXE", url,"abc",sec,"moss.local");

这是我的Sharepoint网站网址....... abc是我想要登录的用户名 sec是密码SecureString密码 moss.local是我的域名,其中“abc”AD用户存在.....

1 个答案:

答案 0 :(得分:0)

试试这个,它似乎对我有用,“用户”可以访问该网站,而不是登录的网站:

ProcessStartInfo startInfo = new ProcessStartInfo(@"c:\Program Files\Internet Explorer\iexplore.exe", "http://server/sites/spsite/page.aspx");
startInfo.UserName = @"user";
SecureString p = new SecureString();
p.AppendChar('p');
p.AppendChar('w');
p.AppendChar('d');
startInfo.Password = p;
startInfo.Domain = "mydomain";
startInfo.UseShellExecute = false;
Process.Start(startInfo);