Ask a Question related to ASP.NET Web Services, Design and Development.
-
Marshall #1
Trying to pass NetworkCredential to WebService
Hello,
I am running W2k3, Visual Studio 2003, Framework version 1.1.4322. I have
one simple asp.net web service and one simple asp.net web app. When I run
the web service directly ([url]http://localhost/mywebservice/Service.asmx[/url])
everything works fine. When I try to call the web service from my web app I
always get the same error:
System.Net.WebException: The request failed with HTTP status 401:
Unauthorized
I also see a new event in my System event log:
Source: Kerberos
Event Id: 4
The kerberos client received a KRB_AP_ERR_MODIFIED error from the server
host/mbell2.<mydomain>. The target name used was HTTP/mbell2.<mydomain>.
This indicates that the password used to encrypt the kerberos service ticket
is different than that on the target server. Commonly, this is due to
identically named machine accounts in the target realm (<mydomain>), and
the client realm. Please contact your system administrator.
I have searched Google Groups what seems like 100 times and I have tried
(what seems like) everything.
Here is my web method:
// Security commented out.
// Security works when running directly
// from [url]http://localhost/[/url]...
//[PrincipalPermission(SecurityAction.Demand,
Role=@"MyDomain\RoleMapWS_Admins")]
[WebMethod]
public bool EnableUser(int userId)
{
try
{
(new UserDAO()).EnableAccount(userId);
return true;
}
catch (Exception ex)
{
throw;
}
}
Here is my web app:
// Private to class
private Open.WebServices.RoleMap.Service ws = new
Open.WebServices.RoleMap.Service();
...
private void Button1_Click(object sender, System.EventArgs e)
{
ICredentials cred = new NetworkCredential(@"mbell", "open",
"MyDomain");
ws.PreAuthenticate = true;
// I have tried
// ws.Credentials = cred;
ws.Credentials = cred.GetCredential(new Uri(ws.Url), "");
try
{
ws.EnableUser(2);
}
catch (Exception ex)
{
throw;
}
}
Thank you for your help,
Marshall
Marshall Guest
-
Pass Date to Webservice
Trying to pass a date to a webservice using a String formatted as '2007-10-30T12:00:00'. Webservice is set up expecting date as a Calendar. Get a... -
How do you pass an array of structures to webservice?
Hello, Does anyone have an example of how to pass an array of strings (ie purchase Id's) from CF to a web service (like weblogic), and then... -
How do you pass an complex data types to webservice?
Hello, I have gone through the simple CFC web services examples where you invoke a call to a web service with a methods and parameters.... but... -
How to pass <br> string to webservice ?
Greetings, I have asp.net page with a textbox. This textbox is used to pass values(mainly strings) to VB.NET webservice using... -
Using .NET Client To Pass ArrayList To Java WebService
"Ashish" <asdd@hotmail.com> wrote in message news:O$Hbp9mQDHA.704@tk2msftngp13.phx.gbl... yes. solution: Don't use types that are platform... -
[MSFT] #2
RE: Trying to pass NetworkCredential to WebService
Hello Marshall,
Did your Web service use Windows integrated authentication and disable
anonymous access? For such a web service, we need to pass a valid
credential to it. for example:
localhost.Service1 myProxy = new localhost.Service1();
myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
or
localhost.Service1 myProxy = new localhost.Service1();
myProxy.Credentials = new System.Net.NetworkCredential("domain\username",
"password", "");
for details, you can refer to:
[url]http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q813834[/url]
Luke
[MSFT] Guest
-
Marshall #3
Re: Trying to pass NetworkCredential to WebService
Thanks Luke,
Yes, the web service is set to use Integrated authentication and anonymous
access is disabled.
My code was passing credientials like you illustrated. The link you
attached guided me to another kb article which solved my problem.
[url]http://support.microsoft.com/kb/811318/EN-US/[/url]
I changed my code to use the CredentialCache class and it worked like this:
localhost.Service ws = new localhost.Service();
System.Net.CredentialCache cache = new System.Net.CredentialCache();
cache.Add( new Uri(ws.Url), "Negotiate", new
System.Net.NetworkCredential("userName", "password", "domain"));
ws.Credentials = cache;
Response.Write(ws.HelloWorld());
Thanks,
Marshall
Marshall Guest
-
Marshall #4
Re: Trying to pass NetworkCredential to WebService
Actually, my statement was incorrect. The problem was that my web service
was running in its own application pool with an identity of a domain
account. So this still is a problem because my web service needs to run in
its own pool because I tie Sql Server permissions to its identity.
"Marshall" <marshall@newsgroup.nospam> wrote in message
news:%23GmyXSGiFHA.2180@TK2MSFTNGP15.phx.gbl...> Thanks Luke,
>
> Yes, the web service is set to use Integrated authentication and anonymous
> access is disabled.
>
> My code was passing credientials like you illustrated. The link you
> attached guided me to another kb article which solved my problem.
>
> [url]http://support.microsoft.com/kb/811318/EN-US/[/url]
>
> I changed my code to use the CredentialCache class and it worked like
> this:
> localhost.Service ws = new localhost.Service();
>
> System.Net.CredentialCache cache = new System.Net.CredentialCache();
> cache.Add( new Uri(ws.Url), "Negotiate", new
> System.Net.NetworkCredential("userName", "password", "domain"));
> ws.Credentials = cache;
>
> Response.Write(ws.HelloWorld());
>
> Thanks,
>
> Marshall
>
Marshall Guest
-
Steven Cheng[MSFT] #5
Re: Trying to pass NetworkCredential to WebService
Hi Marshall,
When your webservice's virtual dir requires Authentication(disabled
anomymous), the clientside need to provide a certain credential for
authentication. For your scenario, that's the ASP.NET webapp. So in your
ASP.NET's webservice calling code, we need to attach a NetworkCredential to
the webservice proxy instance.
As for the further problem you mentioned,
==================
So this still is a problem because my web service needs to run in
its own pool because I tie Sql Server permissions to its identity.
===================
would you provide some further description on this? Based on my
understanding, your ASP.NET webservice can surely to running in its own
application pool (with its own identity) different from the ASP.NET
webapp's.
Looking forward to your response.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Marshall" <marshall@newsgroup.nospam>
| References: <OqRQFA9hFHA.2904@tk2msftngp13.phx.gbl>
<JUjsKACiFHA.2800@TK2MSFTNGXA01.phx.gbl>
<#GmyXSGiFHA.2180@TK2MSFTNGP15.phx.gbl>
| Subject: Re: Trying to pass NetworkCredential to WebService
| Date: Thu, 14 Jul 2005 07:52:46 -0400
| Lines: 34
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Response
| Message-ID: <u7BlPqGiFHA.4000@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
| NNTP-Posting-Host: 66-195-172-195.gen.twtelecom.net 66.195.172.195
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservic es:7405
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
|
| Actually, my statement was incorrect. The problem was that my web
service
| was running in its own application pool with an identity of a domain
| account. So this still is a problem because my web service needs to run
in
| its own pool because I tie Sql Server permissions to its identity.
|
| "Marshall" <marshall@newsgroup.nospam> wrote in message
| news:%23GmyXSGiFHA.2180@TK2MSFTNGP15.phx.gbl...
| > Thanks Luke,
| >
| > Yes, the web service is set to use Integrated authentication and
anonymous
| > access is disabled.
| >
| > My code was passing credientials like you illustrated. The link you
| > attached guided me to another kb article which solved my problem.
| >
| > [url]http://support.microsoft.com/kb/811318/EN-US/[/url]
| >
| > I changed my code to use the CredentialCache class and it worked like
| > this:
| > localhost.Service ws = new localhost.Service();
| >
| > System.Net.CredentialCache cache = new System.Net.CredentialCache();
| > cache.Add( new Uri(ws.Url), "Negotiate", new
| > System.Net.NetworkCredential("userName", "password", "domain"));
| > ws.Credentials = cache;
| >
| > Response.Write(ws.HelloWorld());
| >
| > Thanks,
| >
| > Marshall
| >
|
|
|
Steven Cheng[MSFT] Guest



Reply With Quote

