Monday, July 17, 2006

I posted some Bits Michael and I wrote recently in a WCF Project:

The Constraints-Extensions let you easily define attribute based limitations for input, output and return parameters. Limitations can be set to service contracts operations as well as to data contract data member implementations. The constraints validation gets called at runtime by the WCF infrastructure and the behavior will throw a ConstraintViolationException with descriptive messages in case of a constraint gets violated/the validation fails.

The following constraint attributes have been implemented:

  • Between
  • BetweenExclusive
  • CompareAgainst
  • EarlierThanNow
  • EarlierThanToday
  • EqualTo
  • GreaterEqualTo
  • GreaterThan
  • LaterThanNow
  • LaterThanToday
  • LessEqualTo
  • LessThan
  • Match
  • MaxElements
  • MaxLength
  • MinElements
  • MinLength
  • NotBetween
  • NotEmpty
  • NotEqualTo
  • NotNull
  • Nullable
  • OneOff·    

Data Contract Sample:

[DataContract]
class
TestClass
{
    [DataMember]
    [LessEqualTo(CompareAgainst.FieldOrProperty,"EndDate")]
    public DateTime StartDate;

    [DataMember]
    [GreaterEqualTo(CompareAgainst.FieldOrProperty, "StartDate")]
    public DateTime EndDate;

    public TestClass(DateTime startDate, DateTime endDate)
    {
        StartDate = startDate;
        EndDate = endDate;
    }
}

 

Service Contract Sample:

[ServiceContract, ConstraintsValidatorBehavior]
interface
ITestConstraints
{

    [OperationContract]
    [return:GreaterEqualTo(0)]
    int MethodA(
        [Between(0,100)]
        int a,
        [LessEqualTo(20)]
        double b,
        [NotEmpty]
        string c); 

    [OperationContract]
    int MethodB(
        [Between(0, 100)]
        int a,
        [LessEqualTo(20)]
        ref double b,
        [NotEmpty]
        out string c);

    [OperationContract]
    [return:LaterThanNow]
    DateTime MethodC(
        [GreaterThan(0)]
        int a);

 

    [OperationContract]
    void MethodD(
        [VerifyObject]
        TestClass a);
}


Download at wcf.netfx3.com

C# | Indigo | Projects | WebServices | WCF
Monday, July 17, 2006 12:43:28 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
 Wednesday, May 10, 2006

There we go. Doors are open for NRW06!

20 Speakers, max. 250 attendees a lot of community and networking.

Signup

After you did you can put this onto your blog or website ;-)

Wednesday, May 10, 2006 12:02:12 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [9]  | 
 Friday, November 11, 2005

Friday night Andreas Hoffmann (2nd lead of the VfL-NiederRhein user group) picked me up ad we drove the long way down to the south.

 

Our destination for Saturday morning was the “Chaostage” event of the .NET user group Deggendorf  (http://dotnet-deggendorf.sefnet.de/). I had a session “Introducing the concepts and architecture of ASP.NET“ in the morning and a second one “Hello WebServices – Message-Oriented Programming for distributed systems” in the evening.



We checked in at our hotel in Garching (I won’t tell the name but I’ll tell you a bit about the worst service). Because the waitress served me frozen potatoes with my steak I stood up and walked over to the bar. Just in this moment a voice behind me asked “Is this a codezone keychain? Are you gonna be at Microsoft on Monday?” It was Nicki Wruck (http://spaces.msn.com/members/icebloginfo/PersonalSpace.aspx) the organizer of the ICE 2005 Community together with Frank Solinske (http://spaces.msn.com/members/solinske/PersonalSpace.aspx) IT-Pro Security Guru. Only one nano-second later we drank the first beer together. The geek meet was so exciting that I was just about to forget the bad service of our hotel J

Sunday we fetched Stephan Oetzel (http://stephanon.net/) in Poing. We picked up Michael Willers (http://www.staff.newtelligence.net/michaelw/) Developer Security Guru from the Airport to merge the Security guys in the “Hofbräukeller”. Uwe Baumann (http://blogs.msdn.com/uweinside/) discussed about technical stuff with Andreas and me meanwhile. Later Nicki joined us together with Nico Lüdemann (https://www.openbc.com/hp/Nico_Luedemann/) and Carola Helfert (https://www.openbc.com/hp/Carola_Helfert/).

Monday - Launch Day – started with the Community GetTogether. Stephan and Andreas and I presented the results of the .NET Summit NRW (our community event). As always the time to do some “networking” was toooooooo short - even if we had at least the day before to talk to a few guys. The Launch Party was great. Steve Balmer’s Launch talk was transmitted per satellite into the Lobby of Microsoft in Germany – Great. The only problem again: So many people and such a small amount of time :-) 

Friday, November 11, 2005 9:53:42 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, August 10, 2005

Carefully said I do not like that sharepoint "hijacks" the Internet Information Server. When you create a virtual directory it is just not accessable because SharePoint took over IIS.

Funny fact: This is the second post how to fix issues with IIS and "extension" that cause issues :-)

So i decided to hack a small utility serving my needs:

ExcludeFromSharepoint.zip (3.46 KB)

Enables to exclude applications from sharepoint services through the directory context menu.
Install using the "-install" switch; Uninstall using "-uninstall" switch.

Because I'm running my machine under a LUA (Limited User Account) i wrote the tool in a way that you can install and uninstall it without administative rights - the contextmenu will be installed per user!

if(args[0]=="-install")

{

    RegistryKey _rkey = Registry.CurrentUser;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Classes",true);

    _rkey = _rkey.CreateSubKey("Folder").CreateSubKey("shell");

    _rkey = _rkey.CreateSubKey("Exclude from Sharepoint");

    _rkey = _rkey.CreateSubKey("command");

    _rkey.SetValue(null, App.Application.ExecutablePath + " \"%1\"");

}

else if(args[0]=="-uninstall")

{

    RegistryKey _rkey = Registry.CurrentUser;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Classes\\Folder\\shell",true);

    _rkey.DeleteSubKeyTree("Exclude from Sharepoint");

}

else

{

...

}

 

The Implementation works with the webserver extensions version 4.0 or higher

 

    RegistryKey _rkey = Registry.LocalMachine;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Microsoft\\Shared Tools\\" +

        "Web Server Extensions",true);

   

    foreach(string _subKeyName in _rkey.GetSubKeyNames())

    {

        try

        {

            int.Parse(_subKeyName.Replace(".",""));

            RegistryKey _fpKey = _rkey.OpenSubKey(_subKeyName,true);

            _fpDir = (string)_fpKey.GetValue("Location");

        }

        catch(Exception _ex)

        {

            string _err = _ex.ToString();

            break;

        }

    }

 

and uses the stsadm.exe from the shared tools of the server extensions.

    System.Diagnostics.Process _p = new System.Diagnostics.Process();

    _p.StartInfo.FileName = Path.Combine(_fpDir, "BIN\\stsadm.exe");

    _p.StartInfo.Arguments = "-o addpath -url http://localhost/" +

        _strProjectName + " -type exclusion";

    ...

    _p.Start();

 

ASP.NET | C# | Indigo | Misc | Projects | Security | WebServices
Wednesday, August 10, 2005 5:43:48 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, June 20, 2005

Pierre posted an entry bout impersonation in ASP.NET szenarios.

[Pierre]There are several scenario where you have to use the impersonation in ASP.NET. Consider, for example, you have to save and load files from a network share (file server). In that case, if the web site accept anonymous authentications, you have to impersonate a windows user who has enought privileges to access to that resource.

You have three choices (I guess):

  1. Elevate the ASP.NET process identity - worse case since you could compromise the whole site security
  2. Impersonate a windows user during the single call (http://blogs.msdn.com/shawnfa/archive/2005/03/22/400749.aspx)
  3. Demand the task to a COM+ server application

I think that the last is the best since we have more security and maintenance control
[...]

I agree with him that "Demand the task to a COM+ server application" is the best way of the three he listed. But for me impersonation it is still a don't.

By the way i wanted to post this as a comment but "Comments on this post are closed". Yes this is some criticism on weblogs.asp.net :-) ...

So here my opinion as post in my blog:


Avoid impersonation!
If you need to "redirect a binary that is located on a different box than the webserver to the client" utilize another IIS on the 2nd machine or write a service that returns the binary data.

 

Monday, June 20, 2005 8:57:15 AM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [17]  | 
 Thursday, April 21, 2005

While re-writing a few WebServices for .NET 2.0 i ran across following:

...
public static void WaitProc(object state, bool timedOut)
{
   MyAsyncResult myAsyncResult = (MyAsyncResult)state;
   myAsyncResult.OriginalCallback.Invoke(myAsyncResult);
}
...

This compiles without any problems in Visual Studio .NET 2003 but makes the compiler scream (Invoke cannot be called directly on a delegate) untill you change the lines to the following:

...
public static void WaitProc(object state, bool timedOut)
{
   MyAsyncResult myAsyncResult = (MyAsyncResult)state;
   myAsyncResult.OriginalCallback(myAsyncResult);
}
...

Thursday, April 21, 2005 2:12:24 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [18]  | 
 Thursday, November 27, 2003
I started a new project. A e-commerce solution i wrote once in VB6 as a COM+ component and that is still used by Philips (Consumer Communications)
Thursday, November 27, 2003 8:46:59 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [21]  |