tags:

views:

499

answers:

1

I have a Sharepoint site and I want to open this site in IE by using C# Windows Application. I successfully open the site in IE but my question is how do I send the UserCredentials to the site. It opens the site in IE with defalut credentials. My defalut credentials are username: systemaccount password=123 but i want to open Sharepoint site in IE with some different credentials like username: abc password: 123 (I have "abc" as a AD and Sharepoint User)

here is my code for opening Sharepoint site in IE

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

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

here is my Sharepoint site URL....... abc is my username by which i want to login sec is a password SecureString password moss.local is my domain where "abc" AD user exists.....

A: 

Try this, it seems to be working for me and "user" gets to access the site, not the logged in one:

            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);
Ariel
I am getting the error below when i try to use it:"The directory name is invalid". Any Idea?
Gaby