Tuesday, August 26, 2008

Scotland Visit



Driving from London to Scotland is not a good idea, but still we decided to drive in. It was really tiresome driving the 405 miles through motorway from London to Scotland border. But once we reached Scotland, it was really fascinating to drive the way. The country side is greenish and hilly. The ride through the roads was like playing an NFS race, both the road sides are beautiful and a careless drive can cause a huge disaster.




We reached Glasgow at about 17:30 Hrs and decided to walk around the high streets. The high streets in Glasgow is not so exhilarating, it’s the same like most of the high streets with all the shops around. The next day as per plan we travelled to Gelenco and Lochness. Lochness is a lake flowing through Scotland which is originated from Atlantic Ocean.



It was a wonderful ride to Gelenco, Glenfinnan and Lochness. One side is hilly and the Lochness Lake on the other side. It was so awesome to drive that way. We went to Glenfinnan in the Morning. The Harry Potter rail via duct is over that place. They are running a train service over that viaduct and we waited their till 3:15 PM to see the train going over the viaduct. It horns when it reaches the viaduct to alert all the visitors.



After that we visited a castle located in the Middle of Lochness lake. Its a wonderful view of the Castle from the hill side road.



After that we went back to Glasgow to enjoy the night life of the High Street. The high street glows in the night with different colours.





The next day morning we had breakfast from the hotel and drive back home.

Monday, August 18, 2008

Microsoft Dynamics CRM IFD Process

Microsoft CRM uses active directory to authenticate users. CRM 4.0 supports Internet facing domains and Multilingual applications. The user needs to be registered within the Active directory to access the CRM Application. In my last project I had a chance to explore CRM to the maximum level. In addition to the out of the box functionalities, we had to create some bespoke web applications which are integrated within CRM.

The bespoke application developed in c# using asp.net needs to support the context of the users logged into CRM. So, when we create a CRM Service using the asp.net application, we need to pass in the Context of the asp.net page to the CRM Service class and impersonate the user for creating the service token. The sample code for creating the service is as follows:


private CrmService GetCrmService()
{
try
{
//Services
CrmService crmService = new CrmService();
crmService.CrmAuthenticationTokenValue = GetToken();
crmService.Credentials = CredentialCache.DefaultCredentials;
crmService.Url = CrmServiceUrl;

return crmService;
}
catch (SoapException ex)
{
throw new ExceptionHandler(ex);
}
catch (Exception ex)
{
throw new ExceptionHandler(ex);
}
}

The CRM Token creation needs to be impersonated for the Context user and the CrmAuthentication to work.


private CrmSDK.CrmAuthenticationToken GetToken()
{
try
{

using (new CrmImpersonator())
{
CrmSDK.CrmAuthenticationToken crmToken = new
CrmSDK.CrmAuthenticationToken();

Microsoft.Crm.Sdk.CrmAuthenticationToken token;
if (Context.User.Identity.AuthenticationType
== "CrmPostAuthentication")
{
token =
Microsoft.Crm.Sdk.CrmAuthenticationToken.ExtractCrmAuthenticationToken
(Context, OrganizationName);
}
else
{
token = new Microsoft.Crm.Sdk.CrmAuthenticationToken();
token.OrganizationName = OrganizationName;
}
token.AuthenticationType = authenticationType;
token.OrganizationName = OrganizationName;

crmToken.Actor = token.Actor;
crmToken.AuthenticationType = token.AuthenticationType;
crmToken.CallerId = token.CallerId;
crmToken.CrmTicket = token.CrmTicket;
crmToken.DidUnderstand = token.DidUnderstand;
crmToken.EncodedMustUnderstand = token.EncodedMustUnderstand;
crmToken.EncodedMustUnderstand12 = token.EncodedMustUnderstand12;
crmToken.EncodedRelay = token.EncodedRelay;
crmToken.MustUnderstand = token.MustUnderstand;
crmToken.OrganizationName = token.OrganizationName;
crmToken.Relay = token.Relay;
crmToken.Role = token.Role;
return crmToken;
}
}
catch (SoapException ex)
{
throw new ExceptionHandler(ex);
}
catch (Exception ex)
{
throw new ExceptionHandler(ex);
}

}

Create a Microsoft.Crm.Sdk.CrmAuthenticationToken token for the specific context and assign the token properties to the CrmSDK.CrmAuthenticationToken. All these need to be done within the CrmImpersonator for the asp.net Context to work.