RE: How to tell WebBrowser control what credentials to use?



Hi Linda,

In cases of integrated authentication the browser pops up a dialog box to
prompt the user for a username and password. I want to override this
behavior.
I have done some more research myself and found information about the
IServiceProvider, IProfferService and IAuthenticate interfaces. Howerver, it
is still not clear to me how to tie all of this together. The documentation
is
very scarce on these subjects. Does the browser implement the IProfferService
interface? How can I obtain a reference to it? Can I register my
implementation
of IAuthenticate with it? Again, a little code snippet would be greate.

In cases of WinForms authentication I can use code similar to the following.
This segment navigates to google and puts my name in the search edit control
and sends "Enter". I can do the same in a login form entering the username
and password in the proper fields.

gBrowser.Navigate("http://www.google.com/";);
InternetExplorer gIE = gBrowser.ActiveXInstance as
InternetExplorer;

HTMLDocumentClass docClass = gIE.Document as HTMLDocumentClass;

IHTMLElement query = docClass.getElementById("q");
IHTMLElement2 query2 = query as IHTMLElement2;
query2.focus();
query.innerText = "Adar Wesley";

// Find the HWND of the browser control so I can send it the
keyboard
// messages.
IntPtr IEServerHWND = Win32.FindWindowEx(gBrowser.Handle,
IntPtr.Zero, "Shell Embedding", null);
IEServerHWND = Win32.FindWindowEx(IEServerHWND, IntPtr.Zero,
"Shell DocObject View", null);
IEServerHWND = Win32.FindWindowEx(IEServerHWND, IntPtr.Zero,
"Internet Explorer_Server", null);

Win32.PostMessage(IEServerHWND, Win32.WM_KEYDOWN,
(int)Keys.Enter, 0x000001);
Win32.PostMessage(IEServerHWND, Win32.WM_KEYUP, (int)Keys.Enter,
0xC0000001);

Thanks,

---
Adar Wesley



"Linda Liu [MSFT]" wrote:

Hi Adar,

As far as I know, there're two kinds of authentication modes for web site.
One is form authentication which requires the user to input his username
and password in the web page. And the other is integration authentication
which uses the current windows user's username and password to log on the
web site.

Could you tell me what kind of the authentication mode of the web site
you'll navigate is?

As for the first authentication mode, we could pass the username and
password from windows application to the web page using the method I
mentioned in my previous reply. However, this probably requires script in
the web page to accept the username and password.

As for the second authentication mode, IE always uses the current user's
username and password to log on the web site and we could't change this
behavior. The WebBrowser control is a shell of IE, which means the control
does what IE does when accessing web sites.

If you do want to navigate the web site by the specified username and
password, you could run the windows application as the specified user. To
do this, right-click the windows application and choose Run as. Then input
the specified username and password in the Run As dialog.

Hope this helps.
If you have any concerns, please feel free to let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support


.



Relevant Pages

  • Re: Logged in twice at the same time?
    ... It depends on what kind of login you are talking about. ... If you are dealing with a .htaccess basic login, and the authentication ... a browser can have lots of different ... >Now the first page shows my original username. ...
    (comp.lang.php)
  • RE: Web Forms Auth fails when rfValidator triggered
    ... © 2002 Microsoft Corporation. ... | Content-Type: text/plain ... | | basically has a username field, ... | | If I enter garbage text in BOTH fields, the authentication ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: How to get user id guid
    ... I found the information I needed to use the secur32 dll but when I try to ... convert the username to a unique id, ... My web site is using Integrated Windows authentication with Digest ...
    (microsoft.public.dotnet.security)
  • RE: Adding a virtual FTP folder to IIS
    ... I think we can follow the Form Authentication modal. ... application will use the ASPNET account. ... If we change the username ... Windows identity different from that of the default process identity. ...
    (microsoft.public.dotnet.framework)
  • Re: OWA login problems
    ... But anyway, since just using USERNAME works from the desktop, this indicates ... Maybe one of the authentication ... Outlook Web Access For PDA, ... the Virtual Directory named Exchange and select properties. ...
    (microsoft.public.exchange.connectivity)