开发者

calling web service using current users credentials

I have a web service which is on another server than my web server and that service requires a domain user to function. we have NTLM authentication and my application is a web part. whenever the user enters information and clicks submit the web service is called and it does its job. Can someone please tell me how can I call the web service while passing the users credential开发者_Go百科s to it.I need to have the credentials of the currently logged in user so that it can authenticate against the web service.

Also i tried the below thing but its not working

I tried to use CredentialCache.DefaultNetworkCredentials to pass to a web service. From reading the help this should return the current user domain, username and password.

DefaultNetworkCredentials is actually returning blank values e.g

DefaultNetworkCredentials.Domain = ""


This should be possible when everything is set up to use windows integrated (NTLM) authentication. So that means your webserver and the webserver where the webservice is running. And all the servers have to be in the same domain of course.

You shouldn't pass DefaultNetworkCredentials. Just passing CredentialCache.DefaultCredentials to the webrequest should work, like this:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Credentials = CredentialCache.DefaultCredentials;


There is absolutely no way to do this unless you ask your users to provide their domain/username & password. It is a security feature designed to protect users. If you could simply call CredentialCache.DefaultNetworkCredentials and have everyone's usernames/passwords then you would be able to easily assume their identities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜