Try something like that..:

NetworkCredential credential = new NetworkCredential("username",
"password");
TestService.Service1 ts = new TestService.Service1();
ts.Credentials = credential;
ts.PreAuthenticate = true;
identity.Text = ts.WhoAmI();

It's what I'm using on Windows Mobile, iOS and Android.

Karl

From:  Brian Graham <brian.gra...@russellmcveagh.com>
Reply-To:  "monodroid@lists.ximian.com" <monodroid@lists.ximian.com>
Date:  Mon, 13 Jun 2011 08:37:37 +1200
To:  "monodroid@lists.ximian.com" <monodroid@lists.ximian.com>
Subject:  [mono-android] NTLM Web Services

Hi all, I asked this in the forum but didn't get any replies. Not sure if it
was because no one knows or if you guys didn't get the email. Sorry for the
re-post if you did get it the first time.

Anyway, has anybody successfully connected to a Webservice from Mono for
Android using Windows Authentication? I can connect if Anonymous is enabled
but as soon as I select Windows and give the service proxy the credentials
it comes back with a 401 error. This is the code:
 
                TestService.Service1 ts = new TestService.Service1();
                CredentialCache cache = new CredentialCache();
                cache.Add(new Uri(ts.Url), "Negotiate", new
NetworkCredential("username", "pasword"));
                 ts.Credentials = cache;
                ts.PreAuthenticate = true;
                identity.Text = ts.WhoAmI();

This code works perfectly from a Windows form test project so I know the
webservice itself is ok. I'm using the emulator and have changed the URL to
use the IP address of the host rather than "local", I have also tried "NTLM"
instead of "Negotiate".
 
Thanks in advance for any help.

Regards 
Brian 

Russell McVeagh
OFFICIAL LAW FIRM OF RUGBY WORLD CUP 2011

Winner - ALB Awards 2011: New Zealand Deal of the Year, Australasian Debt
Markets Deal of the Year.

Please think of the environment before printing this email.

________________________________________
This email contains confidential information and may be legally privileged.
If you have received it in error, you may not read, use, copy or disclose
this email or its attachments. In that case, please let us know immediately
by reply email and then delete this email from your system. While we use
standard virus checking software, we accept no responsibility for viruses or
anything similar in this email or any attachment after it leaves our
information systems. If you are interested in establishing more secure
communication between us, please contact our systems administrator by email
at mail.ad...@russellmcveagh.com
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to