I have a Windows Phone 8 project (in C#) with a service reference. Is it possible to set http client credential type to NTLM? I need to provide domain name, user and password.
I'm using BasicHttpBinding with TransportCredentialOnly option. This is done in *.ClientConfig file:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSSoap" maxBufferSize="XXX" maxReceivedMessageSize="XXX">
<security mode="TransportCredentialOnly" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://<address>" binding="basicHttpBinding"
bindingConfiguration="WSSoap" contract="WorkListService.WSSoap"
name="WSSoap" />
</client>
</system.serviceModel>
</configuration>
But I also need to set ClientCredentialType to NTLM and provide ServiceCredentials: Domain, UserName and Password.
This can be easily done in Windows Store apps by implementing partial ConfigureEndpoint method of the generated service class. But I don't know how to do it in Windows Phone 8.
I've noticed that only UserName and Password is available (basic auth):
*.ClientCredentials.UserName.UserName
*.ClientCredentials.UserName.Password
I don't have any phone development experience. Where is what I do at a C# Service Level.
Uri uri = new Uri("http://whatever.com");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
NetworkCredential networkCredentials = new NetworkCredential();
networkCredentials.Domain = "Domain";
networkCredentials.UserName = "User";
networkCredentials.Password = "Pass";
CredentialCache cc = new CredentialCache();
cc.Add(uri, "Basic", networkCredentials); //NTLM can be used here, but Basic usually works.
request.Credentials = cc;
request.Method = WebRequestMethods.Http.Get;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.