Friday, May 21, 2004

Skype and Two C# Guys

Skype
Today, I finally broke down and walked across the street to Frys and picked up a head set so that I could use Skype. So what is Skype? I am so glad you asked, It is a really cool piece of software that allows you to make "calls" over the internet. It uses the "IP" (Internet Protocol) transfer your voice across the ether of the internet to the person receiving the call. Now there is a couple of things, the other person has to be on Skype as well, and there isn't a version for Macs or Linux yet. Ed and I played with it this afternoon, and it is amazing it sounds just as good as the regular landline phone. You don't need anything special except for a headset. If you have a microphone and speakers that will work too. My headset is just a $10 labtech unit and it sounds great. I think this is going to a great tool, and something we will use when working from home.

Two C# Guys
Ed and I have started something we hope is helpful. Not only for each other but for everyone. We've started a blog that we are co-authors on called Two C# Guys. We are going to put code snippet and post about some of the C# issues and projects we run into. It's about sharing the knowledge.

Trying something New

Blogger has comments built into their offering now. So I have enabled them. We will see how they work. If we don't like it we can go back to haloscan comments. Let me know what you all think.

Thursday, May 20, 2004

The Eyes have it

Today my Beautiful Wife and I had an appointment with our Optometrist. It has been about three years since I've gotten my eyes checked. So I was a little nervous. I know that they have gotten a little worse.  Of course sitting in front of a computer all day, typing away doesn't help them much. It went as well as can be expected. The Optometrist seemed like a nice man, and wasn't in a rush to get you out the door. The little boy of course went with us.

 Now that was a new experience for me. Last time I picked out glasses I was by myself and could take as long as I wanted. However after the Little Boy had patiently sat through both My Beautiful Wife's and my eye exam he was ready to go. But I still needed to pick out some frames. With some good advice from my Beautiful Wife I got some frames that will look nice two years from now. (When the insurance allows us to get new glasses) She on the other hand is going to go pick out hers when the little Boy is in school. (A very wise decision.) So Hightlights from the Optometrist visit.

  • The Little Boy pretending to have a conversation with my Brother on a my cell phone which was turned off. It is great to see him using his imagination.
  • One of the office stafff asked The Little Boy if he wanted to sit down and wait, and he  informed her that he was going to be with one of us and he didn't care which, but under no circumstances was he going to sit down for her.(my heart swells with pride on this one)
  • My Beautiful Wife looking at me in my new glasses, and giving me a look of 'you are the handsomest man on earth, after Johnny Dep'.
  • On the way home we stopped at A&W and everyone had a Root Beer Float.

 

Wednesday, May 19, 2004

Be Careful About what you promise

Today at work, I was in an informal meeting with my boss and my boss' boss. We were talking about how one of the project that we hoped to have finished a month ago still isn't finished. Its due in part to people who should care and want it done, just not giving the project the time it deserves. Anyhow we were talking about new functions of the site that were tied to this project. One of them, I thought for sure we had done. It had been assigned to a person a couple of months back, and surely they had it done. So I told my boss' boss that we would generate the code that throw that page up on the site this afternoon. No problem right? As it turns out not so much. This one piece required some research and some terribly repeative copy and pasting (I hate that kind of work). So about a quarter of the research had been done and almost none of the coding. It was one of those things that just fell through that cracks like things sometimes do. Now of course, I had assumed it had all been done and was waiting and my boss's boss had been told it would be done today. Well I am happy to report that it was done today, with just about an hour to spare. I ended up just tearing into it, created an xml document for the data, an xsl to transform the data and used my handy dandy little html generator to create the html. Still even with the little utilities to help make it faster it was a lot more work than I initially thought it would be. However next time, I will check to make sure I have all the facts before I promise something like that.

I know I promised way back when that I would post my little html generator. I still haven't gone through and documented the code yet, but here it is anyway.

(Little disclamier: That the Software comes "as is", with no warranties. None whatsoever.
   This means no express, implied or statutory warranty, including without
   limitation, warranties of merchantability or fitness for a particular
   purpose or any warranty of title or non-infringement. Also, you must pass
   this disclaimer on whenever you distribute the Software or derivative
   works.)

Monday, May 17, 2004

Renfaire Wedding

This weekend My Beautiful Wife and I went to a Wedding that was being held at the Renaissance Pleasure Faire. This was the first Renaissance wedding we have attended, and I have to admit it was a lot of fun. Not many weddings have musicians in Elizabethan costumes, or MooNie the Magnificent. The food was reall good and the weather was very nice. The wedding was lovely, and it really fit the couple well. One of the more interesting events was the toast. They did a 1530s style toast. How this goes, is a little different then the normal best man toast. The Best man stands up, and then the Bride and Groom do as well, each putting their right hand on the left shoulder of the person in from of them. Then they walk around the dinning tables and each person is to follow suite, until everyone at the wedding is following behind. It sort of looks like the Elizabethan version of a congo line. Once everyone is on the party train the best man circles the group around and around till they are in a tight circle around the couple. Then the toasts start. It was very nice and makes everyone feel like a part of the wedding instead of just a spectator.

Sunday, May 16, 2004

6 Months Old

I see that today, this blog is six month old. That's amazing to me. It seemed like only yesterday when I started it and now, 119 post later it has been six months. I've been doing this blog longer than some people have remained married.

Solution to the directory version application security problem

What do you do when you need to secure the directory in IIS, but you need security at the application level as well? Since IIS doesn't give your application all of the username and password information, you can't use directory security. However you have files that need to be secured at a directory level. Of course if you use application security, your application can't communicate with IIS to give it the username and password information. So it's kind of a catch22 isn't it? So when presented with a choose, choice both. My application give access to office files if your Active Directory account is in the correct groups. So that is application level. But with application level security if anyone knows, or can guess the url of the documents, they can view them right in their web browse. Now what is the use of setting up Active Directory groups and using the System.DirectoryServices namespace, if in the end anybody can browse to it.

The solution that I can up with was to lock down the my content directories in IIS. No rights to anyone. Then I created a page to be the proxy between the web and the NTFS level. So now you can only browse to the files if you have the correct authorization from the you Active Directory group, and if you don't it takes you to a login screen. What's really interesting about this solution is it envolves a lot lets code then you may think. The article I based my code on is in the Microsoft knowledge base, Article -306654.

privatevoidPage_Load(object sender, System.EventArgs e)

{

FileInfo MyFileInfo;

long StartPos = 0, FileSize;

string filepath = "";

try

{

//Check to see if there is anything in the QueryString.

if (Request.QueryString["doc"].ToString() != "")

{

//Set filepath to Querystring.

filepath = Request.QueryString["doc"].ToString();

}

}

catch

{

//If the Querystring is empty send the user back to Default.aspx.

Response.Redirect("Default.aspx");

}

try

{

//Set the appropriate document type

Response.ContentType = "Application/pdf";

//Response.ContentType = "Application/pdf";

//get the physical file path

stringstrFilePath = utilities.getPath(filepath);

//instantiate the FileInfo class

MyFileInfo = newFileInfo(strFilePath);

//Get the size of the file.

FileSize = MyFileInfo.Length;

//Write the file directly to http content output stream

Response.WriteFile(strFilePath, StartPos, FileSize);

Response.End();

}

catch(Exception err)

{

//Write to custom error logging function

logging.writeError(err.Message.ToString());

}

}

So Pretty straight forward. You locate the document give the Response.WriteFile function the files path and a few properties and your aspx page opens up as if it were that document. Of course the one thing you have to be mindful of is the Content Type. That  must be set to the correct MIME type for the type of file you are opening. Wher are some of the types.

  • "text/HTML"
  • "image/GIF"
  • "image/JPEG"
  • "text/plain"
  • "Application/msword" (for Microsoft Word files)
  • "Application/x-msexcel" (for Microsoft Excel files)
  • I have ran in to a couple of issues worth mentioning. First in some cases with users that are running Internet Explorer, the page will appear to be completely blank. The issue seems to be that IE is second guessing the content type and doesn't display anything. The fix is simple, but on the client side, in their pdf reader they need to disable view pdf in browser. Here is an article that covers all of the variations of Acrobat and Internet Explorer settings to do that

    Second, is speed, with files that are larger than 2MB it takes a little longer. Not a lot, but it is noticable. This is because our ASPX page is reading the file in binary and rewriting it in binary to the browser. I haven't figured out how to speed that up just yet. If I do I will post it. However a document being 10 times more secure, is worth it being a little slower.