Thursday, September 20, 2007

How to really disable My Sites on MOSS 2007


So, I have been modifying a MOSS site. One thing I was trying to do is disable the My Site / personal site completely. There are links on the web on how to disable it here, here and like 10,000 other places. They all say the same thing.

Well that is all fine and dandy if you want to just hide the UI. However, if you are also doing custom profile fields that require the user to have a profile in the central admin the above way doesn't work, doh! When you add a profile in the central admin and then you go view the user's information on a specific web application it gives you the MySite. I said I didn't want that!

I finally found the solution and I thought I would blog about it in case it could help someone else.

What you have to do is go disable the actual MySite feature. To do this Navigate to the bin folder that has stsadm.exe in it (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN in my case) and then fire off the following command.

stsadm.exe -o deactivatefeature -name MySite

After that the MySite feature is disabled and life is good.

For an extra tidbit the file MySiteFeatureElements.xml had an ASPX control that is for redirection which was the thing causing me my grief.

Listing out all sites and their document roots in .Net


So, I had a problem today that required me to find all document roots for an IIS server which is trivial (open up IIS manager, silly) on a single box. However, in this case the code would run on random boxes and I would never know what was on there.

Below is the solution I came up with is below. Hopefully it will be helpful to someone else.

Note: I had to include System.DirectoryServices into the references and in the using/imports clause.


DirectoryEntry de = new DirectoryEntry();

de.Path = "IIS://LocalHost/W3SVC";

foreach(DirectoryEntry deTmp in de.Children)
{
// If the server doesn't have a state it is more
// than likely an app pool or something similar so we don't care
if(deTmp.Properties["ServerState"].Value != null)
{
DirectoryEntry deDocRoot = new DirectoryEntry();
deDocRoot.Path = "IIS://LocalHost/W3SVC/" + deTmp.Name + "/ROOT";

if(deDocRoot.Properties["path"].Value != null)
{
string DocRoot = deDocRoot.Properties["path"].Value.ToString();

// Do whatever you want to with the values now...
}
}
}


I hope someone else finds this useful.

Also, the MSDN documentation for these object is here.

New operator in .Net 3.5


Scott Guthrie has a nice write-up on the ?? operator that is coming out in .Net 3.5. Check it out if you are going to be doing any .Net development soon.

Now, what can I make in .Net to work with the new features...hmm....Any ideas?

Tuesday, September 18, 2007

How to handle a base64binary type


I ran into an issues yesterday on how to handle a base64binary type being returned from a web service. It was a pain to find the answer or maybe my brain wasn't on (very plausible). So, I am going to post it up for some poor soul, even if it is me who is the poor soul again :).

First let me say that a base64binary type is basically just a byte array base64 encoded.

In my example I am returning this base64binary type as a download but there are a few different ways to use it.


byte[] attachment = new byte[15]; // pretend this is the base64binary :)

Response.BinaryWrite(attachment);


Way too easy, just took me awhile to find. Another way you can do screw around with the values is doing something like.


byte[] attachment = new byte[15]; // pretend this is the base64binary value

for(int i = 0; i < attachment.Length; i++) {
Response.Write(Convert.ToChar(attachment[i])) ;
}


This is a little bit more code and little harder to read but works as well.

I am sure there are like 10 other ways to screw around with these values but both of these worked, so, hopefully this will help someone else.

Wednesday, September 12, 2007

Unintended Benefits


Recently I have been taking the bus to work. There are two great things about this:
1. I don't get as much road rage
2. I can read

Which one is more important? Well if I had a handgun I would say number one but since I don't I will have to go with being able to read. Reading and pushing my knowledge is very important to me, but, as I have been taking on more side projects and working it has been tougher to read as much as I want to. Taking the bus makes it easy because with my NADD I can't just sit and watch traffic I would go INSANE!

So, what unintended benefits are you missing?

Tuesday, September 04, 2007

Are you working hard or smart?


Earlier today I was reminded that hard work != best. If you have not read Seth Godin's blog post here, I would suggest taking the 3 minutes to read it.

People who know me (and who doesn't who read this blog :P), know that I work a lot. Currently I am taking a break from working just to write this. I love most of my work even if it doesn't seem like it all the time. But I don't know if it is the smartest work I could be doing. I could be working on my applications that would create long-term revenue instead of this short-term crap. Not sure what is best I know I need to balance but boy is it hard.

Anyone have any suggestions? :)

Well back to work.

Follow up


It has been roughly 6 months from my last post about switching careers so I thought I would do a follow up as I said I would.

For the most part doing actual security work is pretty decent. Although, it is slower paced and more focused on research than producing. This is understandable when you realize that most security testing/work is just knowing more specific details than the person who implemented the feature and also understanding how people think / implement functionality.

One thing I don't like so far is security testers/hackers being grouped in with functional testers. No, I don't think security testers are higher up than functional testers, but I do think they are specialized in a very different area. Yes, there are parallels and they both can benefit from each other, but, it can be said that most technology things are beneficial to each other. For example development knowledge helps you be a better tester, networking helps you be a better security and/or developer and vice versa. This can turn off people because your career growth gets stunted, I know it is a huge turn off for me right now.

On the flip side it is an awesome feeling when you find a big bug and it affects a lot of people. For the most part it is just a job, I am not as energized as I thought I would be about it. Not sure if it is because of the team I am on or the profession, time will tell.

Development:
I still love development and it frustrates me too :). I tend to relate stuff back to development and some days I want to go off and just code stuff instead of researching crap. I look for things to code while I don't look for things to hack. I still get pissed when software is just un-usable or poorly done.

So, basically I haven't gained much insight since my last post. Lets see what happens in the next 6 months.

Sunday, September 02, 2007

What do you call an axe stuck in a hard drive? An embedded device, har har har. Alright enough corniness back to my coffee.

Saturday, September 01, 2007

Condemning Code


Since I just purchased my new house I am learning all sorts of "cool" things like the fact that a furnace can be condemned. But, this nice tidbit of knowledge made me think about coding as many other things do. There is a fairly common term in programming called code smells which allows opinionated coders (like me) to say stupid phrases like "your code smells." So, what is my point? It is I think we should start condemning code if it smells bad enough. Basically if the code being looked at smells enough it should just be re-written instead of trying to fix it.

What is everyone else's thoughts?