Skip to main content

Hi

Consider this:

Server One - K2 Server and K2 Studio

Server Two - MOSS Web Server. MOSS Portal is using Basic Authentication.

I drop a Web Service and Assembly event onto the canvas and add a web reference. If I don't specify credentials, I get a 401 error - this is expected as I am running K2 Studio under an account that is not trusted for Kerberos delegation. So I hard code the K2 service account and can proceed.

Export the process and the web service call works fine, as expected.

 The code behind the web service call looks like this:

        CredentialCache mycredentialCache = new CredentialCache();
        NetworkCredential credentials = new NetworkCredential("k2serveraccount,"password","domain");
        NetworkCredential credentials = new NetworkCredential(SourceCode.K2Utilities.GeneralMod.GetCredentials(oWebService.Url));
        mycredentialCache.Add(new Uri(oWebService.Url), "Negotiate", credentials);
        mycredentialCache.Add(new Uri(oWebService.Url), "NTLM", credentials);
        mycredentialCache.Add(new Uri(oWebService.Url), "BASIC", credentials);
        mycredentialCache.Add(new Uri(oWebService.Url), "Digest", credentials);
        oWebService.Credentials = mycredentialCache;


I would like to remove this, and insert just:

 

oWebService.Credentials =
SourceCode.K2Utilities.GeneralMod.GetCredentials(oWebService.Url);



 Which compiles and exports fine - but when it runs, it fails with a 401 error.

Essentially - I don't really want the K2 Server login details either in plain text in the source, or in plaint ext in the string table. Also it is a lot neater to just have it on one line. 

 Can anyone suggest how I can make this work? I assume it has something to with the fact that the portal is using basic authentication? Can anyone offer an insight into how the K2Utilities.GeneralMod.GetCredentials presents the credentials to the web service?

 Many thanks in advance for any help

Richard
 


 

Ok, well I did some reading and assume that because both:

System.Net.CredentialCache.DefaultCredentials and System.Net.CredentialCache.DefaultNetworkCredentials are "applicable only for NTLM, negotiate, and Kerberos-based authentication" that the same applies to SourceCode.K2Utilities.GeneralMod.GetCredentials.

 Rather than mess around with it any further, I am simply calling the web service from an internal extension of the SharePoint web application that uses NTLM. A little bit of hassle but it works just fine and I don't need to expose plain text passwords anywhere.

Thanks, Richard
 


Reply