šljaker
šljaker

Reputation: 7374

Basic authentication for the web service

I'm having problems to set up the basic authentication for the web service. I'm writing standard web service (not WCF) using .NET 4.0

In the web.config I have the following settings:

<configuration>
    <system.web>
        <identity impresionate="true" />
        <authentication mode="Windows" />
    </system.web>
...
</configuration>

The web service has one method:

[WebMethod(Description = "Returns currently logged in user.")]
public string WhoAmI()
{
    return "You are logged in as: " + System.Threading.Thread.CurrentPrincipal.Identity.Name;
}

The test server is virtual machine located on the same domain as my machine. When I access it, I don't get anything for the CurrentPrincipal.Identity.Name.

I also tried to access the web service using the soapUI. I entered my username, password and domain but I still can't get it to work.

Any help would be appreciated.

Upvotes: 2

Views: 1406

Answers (2)

maycil
maycil

Reputation: 764

On IIS (inetmgr) you can find Authendication Method window.(WebService1->Properties->Directory Security->Authendication Controls->Edit Button)

You can choose Authendicated access. (Diggest,Basic,Integrated Authendication) After that changing your method will work as you want.

Upvotes: 1

mlibby
mlibby

Reputation: 6724

Does it work if you change impresionate to impersonate?

Upvotes: 0

Related Questions