Translate

Home > January 2012

January 2012

How to Read/Write registry in C#?

Tuesday, January 17, 2012 Category : 0

using Microsoft.Win32;
 
public string GetRegistryValue(string key)
{
   return Convert.ToString(Registry.GetValue
                (@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", "OLD"));
}

public void SetRegistryValue()
{
   Registry.SetValue(@"HKEY_CURRENT_USER\Software\Yahoo\Common", "Sandy", NEW");
} 

the caller was not authenticated by the service : Problem Solution

Saturday, January 7, 2012 Category : 0

1Go to your Client Project Properties.
a. Go to services tab
           Enable this settings and use authentication mode windows
2. change app.config file inside client project with this two sample line
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
          </security>

3. change app.config file inside service project
<security mode="None">
            <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
          </security>

4. in client code when you creating service instance and calling for a service use this line to provide login info in service pc.

               Service1Client client = new Service1Client();
                client.ClientCredentials.Windows.ClientCredential.UserName = "ETLIT-1";
                client.ClientCredentials.Windows.ClientCredential.Password = "etl";
                client.ClientCredentials.Windows.AllowNtlm = false;
                client.ClientCredentials.Windows.ClientCredential.Domain = "ETLIT-1-PC";
                Console.WriteLine(client.addNumber(23, 2));

[Note here we using wsHttpbinding but our security mode set to none. if you use it "message" then you must set "negotiateServiceCredential=true" , and if you do this then you must add your security sertificate info before using this service from a remote pc ]

WCF Error : The token provider cannot get tokens for target

Category : 0


The inner exception is a much better source for this error message. The underlying message was

The NetworkCredentials provided were unable to create a Kerberos credential, see inner execption for details.
And from this exception the inner one’s detail was
InitializeSecurityContent failed. Ensure the service principal name is correct.
Adding clientCredentialType="None" solve this problem… by default it’s not None, but “Windows” which is relying on Kerberos.
<message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false" />
Then,  I had the problem
The service certificate is not provided for target 'http://localhost:10000/Service1.svc'. Specify a service certificate in ClientCredentials.
So I found this post on StackOverflow and remove everything under security to add only the mode to the security node to None.
<security mode="None"/>

Powered by Blogger.