Thursday, January 31, 2008

SSOProvider for BDC doesn't work for .NET 3.5

If you are using Visual Studio 2008 to build a SSOProvider for BDC in Sharepoint 2007 it might not work.
It'll work if you build the dll by targetting it for .NET 2.0 framework.
Looks like Sharepoint 2007 can't load the SSOProvider assembly if the target runtime is 3.5

~Abhishek

Writing a simple SSOProvider for BDC in Sharepoint 2007

Here's a simple code which i wrote to enable BDC call webservices which support basic authentication.

I started with msdn sample for a simple pluggable SSOProvider and hardcoded the user according to my own needs.
I was getting an exception when Sharepoint tried to call this SSOProvider as it expects that GetRestrictedCredentials method of ISSOProvider is also implemented. I just returned the output of GetCredentials from this method and was able to call the service successfully.
Here's the code for reference ....


public class BasicAuthentication : ISsoProvider
{
#region ISsoProvider Members
public SsoCredentials GetCredentials(string AppID)
{
try
{
SsoCredentials ssoCreds = null;
switch (AppID)
{
case MyAppName:
{
//this is our application so return the basic credentials
ssoCreds = CreateSsoCredentials(AppID);
break;
}
default:
{
//not our application so let's not even let it have access to our SSO
throw new SingleSignonException(SSOReturnCodes.SSO_E_ACCESSDENIED);
}
}
//return the created SSO Credentials
return ssoCreds;
}
catch (SingleSignonException singleSignonEx)
{
EventLog.WriteEntry("GetCredentials has thrown SSO Exception");
throw;
}
catch (Exception exception)
{
EventLog.WriteEntry("SimpleSSOProvider", exception.ToString());
throw new SingleSignonException(SSOReturnCodes.SSO_E_EXCEPTION, exception);
}
}
private SsoCredentials CreateSsoCredentials(string AppID)
{
SsoCredentials ssoCreds = new SsoCredentials();
ssoCreds.Evidence = new SecureString[2];
ssoCreds.Evidence[0] = MakeSecureString("D034677M1");
ssoCreds.Evidence[1] = MakeSecureString("Welcome1");
// Put the User Name and Password values into the credential object
ssoCreds.UserName = ssoCreds.Evidence[0];
ssoCreds.Password = ssoCreds.Evidence[1];
return ssoCreds;
}
private SecureString MakeSecureString(string sourceString)
{
if (sourceString == null)
{
//we don't have a good source string so return null
return null;
}
SecureString secureString = new SecureString();
foreach (char ch in sourceString)
{
//append each character in the source string to the end of our secure string
secureString.AppendChar(ch);
}
return secureString;
}
public SsoCredentials GetRestrictedCredentials(string AppID)
{
return this.GetCredentials(AppID);
}
public SsoProviderInfo GetSsoProviderInfo()
{
//This method is required for all SSO Providers.
SsoProviderInfo ssoProvInfo = new SsoProviderInfo();
//setup the information about our sso provider
ssoProvInfo.AssemblyName = Assembly.GetExecutingAssembly().FullName;
ssoProvInfo.Vendor = MyAppName;
ssoProvInfo.Version = "1.0.0.0";
return ssoProvInfo;
}
private const string MyAppName = "MyApp";

////Continue to implement other methods of the interface
////You can safely throw NotSupportedException from these methods...
}


~Abhishek

Calling SAP ESOA services from .NET

If you are calling a webservice from SAP ESOA world and are getting an InvalidOperationException then don't be surprised.
You just need to open the wsdl file and replace '' with '' and recreate the proxy. It should start working ....

According to a document on https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0421f9a-4c9e-2910-1085-a45f8e813324 SAP supports document style wsdl while Microsoft Visual Studio expects a RPC style wsdl and hence the runtime exception.

Hope this helps anyone who's struggling with calling SAP ESOA services from .NET world...

~Abhishek

Friday, January 11, 2008

BDC Metaadata Editor

Finally after struggling for one full day i got a BDC Metadata Editor from Microsoft in their SDK.
The SDK can be downloaded from http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&displaylang=en
Happy BDC'ng...

~Abhishek

Thursday, January 10, 2008

Setting a reference to assembly in GAC

I wanted to set reference to an assembly and couldn't find a direct way to do it from Visual Studio.
So here's how i hacked into registry and was able to view the GAC as i view any file in windows explorer.

Here is how:
1) Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion in the RegEdit
2) Add a new Binary Value DisableCacheViewer and given it a value of 1
3) Navigate to C:\WINDOWS\assembly and you can see the contents of the folder as sub folders, not the standard GAC Viewer


Happy coding...

~Abhishek

Wednesday, January 2, 2008

Using ISO Images without burning them on DVD

I am trying to use ISO images to install some stuff on my machine and i found it very strange that not many easy to use tools are available on web to read ISO files and use them. Most of the tools allow you to burn the iso image on a DVD and then use them. Now this is pretty time consuming process.
So i googled hard and found an unofficial tool from microsoft which can be downloaded from http://download.microsoft.com/download/7/b/6/7b6abd84-7841-4978-96f5-bd58df02efa2/winxpvirtualcdcontrolpanel_21.exe
Its probably unsupported from Microsoft but is very easy to use. Don't forget to read the readme file which you would get once you extract the exe.

So happy mounting the ISO images...

~Abhishek