in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

prosinac 2009 - Posts

  • Developing Services for AppFabric Worker Feature (Dublin)

    When developing Workflow Services or WCF service which should run in AppFabric Worker Feature (if you are confused read simply “Dublin”), one could ask is possible to develop it without of AppFabric at all. The answer is typical architect answer: “It depends” :).

    If you do not use any host specific features in your service the answer is: “Yes, you can.”. To do this you nee VS 2010 and IIS 7.5 (delivered on on Win7 or Win2008 R2) installed.

    First create Declarative Workflow Service application as shown at the picture below:

    image 

    Then go to project settings – > Web and select “Use local IIS Web Server”.

    image

    If you try to create Virtual Folder (if UAC is enabled you must start VS with elevated privilege) for application and IIS Metabase and IIS 6.0 configuration compatibility features are not installed following error appears:

    image

    To workaround this install required windows features as follows:

    image

    Now you can develop you service without AppFabric (“Dublin”). After the service is completed, install it on an existing AppFabric instance.

    Posted pro 27 2009, 12:59 by anonymous
    Filed under: ,
  • Using of Impersonation with DataServices

    When working with web services and ADO.NET services (O-data) you will sometimes have requirement to invoke ADO.NET Data Service from one service.
    For example, imagine there is a Silverlight application which invokes some operation DoSomething on Service1. Now imagine the Silverlight application has line of code which invokes the ADO.NET Data Service:

    JdMasterEntities ctx = new JdMasterEntities(this.m_JdMasterUri);

    var
    query = from user in ctx.Entity select user;

    IEnumerable<Entity> list = dataQuery.Execute();

    return ctx;

    If your service operation DoSomething uses impersonation (Link I, Link II) all will work fine, because the browser network stack in Silverlight does this for you.
    This is example of using of impersonation:

    // Here you need to impersonate imperatively later in code.
    [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
    public QueryTransportResponse DoSomething(QueryTransportRequest query)

    or

    // WCF impersonates for you declaratively.
    [OperationBehavior(Impersonation = ImpersonationOption.Required)]
    public QueryTransportResponse DoSomething(QueryTransportRequest query)

    The browser do it for you means the browser prepares the token of interactive user for impersonation before request is sent to service. If you didn;t understand what this means take a look on next example. Imagine you write the application which needs to invoke DoSomething. Because you know that DoSomething will perform impersonation you have to send the toke which can be impersonated.
     
    To make this working do following:

    MyProxyClient proxy = new MyProxyClient()

    // If the service needs to access resources at its local machine. For example to invoke the ADO.NET data service
    // which is hosted at the same machine as Service1 (implements operation DoSomething).
    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

    or

    // If the service needs to access resources at some other machine. For example if the ADO.NET data service is hosted at other machine
    // than Service1.
    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;


    proxy
    .DoSomething();


    If you want to invoke the ADO.NET data service from some service operation you will do it as follows:

    JdMasterEntities ctx = new JdMasterEntities(this.m_JdMasterUri);

    var
    query = from user in ctx.Entity select user;

    DataServiceQuery<Entity> dataQuery = (DataServiceQuery<Entity>)query;

    IEnumerable<Entity> list = dataQuery.Execute();

    return ctx;

    But if the ADO.NET data service requires windows authentication you need to append credentials to web request.

    ctx.Credentials = System.Net.CredentialCache.DefaultCredentials;

    The question is now what credentials will be used when you setup DefaultCredentials? The typical architect answer is “It depends” :)

    The value of default is following call:

    System.Security.Principal.WindowsIdentity.GetCurrent()

    Whatever this is it will be passed as credentials to the next hop (in this case ADO.NET data service). By default (if no impersonation is used) this is the pool identity like "IIS APPPOOL\\DefaultAppPool".

    If the operation DoSomething allows impersonation, but not requires (see example above) you need to do imperative impersonation:

    if (Thread.CurrentPrincipal.Identity is WindowsIdentity)
    {
     
    using (((WindowsIdentity)Thread.CurrentPrincipal.Identity).Impersonate())
     
    {
        . . . call to ado.net data service . . .
         // System.Security.Principal.WindowsIdentity.GetCurrent() 
         // gives: DOMAIN\user_who_open_the_browser_which_invoked_DoSomething_within_Silverlight_application.

      }
    }

    If the ADO.NET data service is permitted for anonymous users of for the application pool user, you do not have to do anything.
    If the ADO.NET data service is permitted for specific windows users who started the Silverlight application you need to impersonate.

    this is why the answer was “It depends”.

  • TFS 2010 Error: Automated build time outs

    Problem description

    When using automated builds in TFS 2010 it may happen that the build for some reason just do not execute. The interesting thing in this failure (see picture below) is that the build process starts properly, prepares all required assemblies for build and falls into sleep without of any error. Because I couldn't notice any error I let the build to run the whole night. After exactly 4 hours of running the build has finally failed with an error:

    Run for 4 hours …” or
    “TFB 210703 Agent scope ‘Run on Agent timed out waiting for an agent with name ‘*’ and tags ‘’.

    Four hours is the value which can be changed in the build definition, but it will not help you solve the problem.

    Solution

    To solve the problem take the currently active Agent (active for failed build) offline and create the new build agent. Trigger the build and all will work fine.

     

    image

  • How to enable ASP.NET on WinServer2008 R2?

    When working with Windows Server 2008 R2 in order to run you ASP.NET application you will need to install ASP.NET feature on the “Web Role”. To do this open “Server Manager” and lookup “Web Server (IIS)” under Roles node.

    image

    Select ASP.NET as shown on the picture above and look in “Role Service” for ASP.NET service as shown at the next picture.

    image

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems