see sharp RSS 2.0
# Friday, 20 February 2009
Basic Authenitcation is a - not so secure - method of authenticating users to a web server.
The username and password are sent in the HTTP request header with Base64 "encryption" which is as good as plain text.
However at some point you may have or may want to do just that, either because there is still no trust between organizations (believe me, the world is good :-)) or just because its too easy and other methods are way too hard to implement.
Now there you are, how do you add a header to a HttpRequest in plain c#?

Follow these steps:

  1. Generate the proxy using WSDL.EXE. Search MSDN on how to do that.
  2. Add this function to the partial class:

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
          HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
          if (PreAuthenticate)
                NetworkCredential networkCredentials = Credentials.GetCredential(uri, "Basic");
                if (networkCredentials != null)
                      byte[] credentialBuffer = new UTF8Encoding().GetBytes(networkCredentials.UserName +":" + networkCredentials.Password);
                      // Note the space after Basic
                      request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);
                      throw new ApplicationException("No network credentials");
          return request;

  3. within the client using your proxy add the following:

    // these are NOT my real credentials
    NetworkCredential netCredential = new NetworkCredential("Elvis", "Graceland");
    Uri uri = new Uri(svc.Url);
    ICredentials credentials = netCredential.GetCredential(uri, "Basic");
    svc.Credentials = credentials;
    // set PreAuthenticate as it is checked !!!
    svc.PreAuthenticate = true;

Thats it....

Friday, 20 February 2009 14:48:23 (Mitteleuropäische Zeit, UTC+01:00)  #    -
C# | Webservices | Authentication
# Friday, 13 February 2009
A trace filter is a nice thing, it can decide whether to log a message or not.

Two filters exist in the framework, and they are covered widely on MSDN.

Writing a custom filter is quite easy.
Just derive your filter class from  TraceFilter, override the one and only method ShouldTrace (which returns bool) and there you go.

Now the only thing left is to add the filter to the listener in your applications config file.

Happy Tracing...

Oh yes, here are the files:
Friday, 13 February 2009 14:35:41 (Mitteleuropäische Zeit, UTC+01:00)  #    -
Tracing | C#
So, ever played to much with a CLM test or demo environment and the database is full of old requests?
You can clean the database by running the ILM configuration wizard.
The wizard wil drop (and recreate) the database as part of the final configuration.
If you want the certificates from your current installation, don't let the wizard create new service account certificates.
There is a checkbox for this option.
I've done this for CLM 2007 (FP1) but I did not test it for newer releases (so i give no warranties).

Friday, 13 February 2009 14:28:44 (Mitteleuropäische Zeit, UTC+01:00)  #    -
# Wednesday, 11 February 2009
There are two possible reasons for a BIND Problem in CLM
  1. Not in trusted sites
    If working with CLM, be sure to add the CLM website to your browsers Trusted Site list.
    Many problems like links that do not work, Active Directory (AD) Bind problems and of course ActiveX problems

  2. Service Principal names
    In order for Kerberos to work the SPN must be correctly set. Verify its setting by issuing SETSPN -l MYDOMAIN\serviceaccount where the serviceaccount is the account the IIS App Pool is running.
    It should contain something like
    If you are using WIndows 2008 you can check for duplicate SPNs by issuing setspn -X
Wednesday, 11 February 2009 14:20:08 (Mitteleuropäische Zeit, UTC+01:00)  #    -
Authentication | CLM
<2009 February>
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Any link on this site may lead to an external website that is not under my control and that external website might show an opinion that is not mine.

© Copyright 2018
Hannes Köhler
Sign In
Total Posts: 39
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2018, Hannes Köhler
DasBlog theme 'Business' created by Christoph De Baene (delarou)