Reputation: 361
When I try to access a webservice I get the following error message:
The username is not provided. Specify username in ClientCredentials.
I do make new credentials as seen in the following code:
public AppWebService_PortClient openConn2()
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
BasicHttpSecurityMode sMode = binding.Security.Mode;
EndpointAddress adress = new EndpointAddress("myURL");
AppWebService_PortClient client =
new AppWebService_PortClient(binding, adress);
client.ClientCredentials.Windows.ClientCredential =
new System.Net.NetworkCredential("Username", "Password", "Domain");
string userName =
client.ClientCredentials.Windows.ClientCredential.UserName;
//client.ClientCredentials.Windows.AllowedImpersonationLevel
//= TokenImpersonationLevel.Delegation;
return client;
}
if i read out the credentials as in string userName
i get the right username. Why do i get that error?
Upvotes: 1
Views: 1042
Reputation: 28268
You should probably use
client.ClientCredentials.UserName.UserName = "Username";
client.ClientCredentials.UserName.Password = "Password";
instead.
Upvotes: 0
Reputation: 116
Looks a bit like this issue: Setting ClientCredentials: getting "Username is not provided" error
Which had the following "solution". Which might apply to your case.:
Do you have security mode, clientCredentialtype configured appropriately in your configuration files? Here is a blog post that very closely matches your question. I hope this helps!
http://amadotech.blogspot.com/2009/11/error-username-is-not-provided-specify.html
Actually there're three causes with my application:
Security mode was not appropriae. Client credential type was not appropriate. The call missed passing the required Username and password.
Upvotes: 1