Downloading a file from a remote server with network credentials

Man, was this a pain in the butt.  Seems like downloading a file from a remote PC would be easy, but 'taint.  This worked great for me,  your mileage may vary.

   1:  'First we set up all of the filenames and locations, making heavy use of app.config.
   2:  Dim filename As String = String.Format("{0}-{1}-{2}.txt", CDate(checkDate).Year.ToString, CDate(checkDate).Month.ToString, CDate(checkDate).Day.ToString + 1)
   3:  Dim RemoteFile As String = String.Format("\\{0}\{1}\{2}", My.Settings.IpNumber, My.Settings.LogDirectory, filename)
   4:  Dim LocalDirectory As String = String.Format("{0}logs\", My.Settings.ReportLocation)
   5:  Dim LocalFile As String = String.Format("{0}{1}", LocalDirectory, filename)
   6:  'Hey, check for the localdirectory
   7:  If Not Directory.Exists(LocalDirectory) Then
   8:    Directory.CreateDirectory(LocalDirectory)
   9:  End If
  10:  'Then we set up a little security
  11:  Dim myClient As New System.Net.WebClient
  12:  Dim myCreds As New System.Net.NetworkCredential(My.Settings.Username, My.Settings.Password)
  13:  'Log the fact that we are starting.
  14:  My.Application.Log.WriteEntry(String.Format("Starting download of file {0}", fileName))
  15:  'Set up the securit
  16:  myClient.Credentials = myCreds
  17:  'Now we actually try and get the file.
  18:  Try
  19:    myClient.DownloadFile(RemoteFile, LocalFile)
  20:  Catch uae As System.UnauthorizedAccessException
  21:    My.Computer.FileSystem.WriteAllText(LocalFile, String.Format("The file path to file {0} was not available at the time of this posting.", file), True)
  22:  Catch ex As Exception
  23:    My.Application.Log.WriteException(ex)
  24:  End Try
  25:  My.Application.Log.WriteEntry(String.Format("Finished download of file {0}", fileName)) 
  26:   

 

Did this as part of a project at Wendy's.  Part of the Classic Posts collection.  (heh)

Pistons

In the world of taijutsu, legs are like pistons. You let the pressure out of them to lower yourself to the ground, and increase the pressure to lift yourself up. Take Morote Gari. You drop to a sprinters stance - releasing the pressure in your knees (performed by the calves and thighs) and position yourself at the knees of uke, then increase the pressure in your knees to take uke to the mat.

Hokojutsu is the same thing. The key to moving my bulk around silently is to not place my leg, but lower it, and then lower my weight onto it. If I just place it, I thump. If I lower it, I don't. It's a totally different way of thinking.

There are a bunch of examples. When I perform Oni Kudaki, for example (in the classical way) I slide into uke with my back foot and lower by center of gravity on my pistons to take balance. Then I raise myself after I get the lock on the elbow. The legs work just like hydraulics to lower and raise my body.

Preparation

It's surprising how much preparation is a part of hensojutsu. I have been reading On Acting by Sanford Meisner, and his approach to preparation has me thinking a lot about hensojutsu and reality. Meisner says that 'acting is living truthfully under imaginary circumstances.' Admittedly, if you have one hell of an imagination you can just jump up and do what is required under the circumstances.

I don't.

So, Meisner has his students prepare. The difference is, he has them prepare for the emotion not the action. For instance, say you have a scene where your sister has died. But you are an only child. You don't know what it would feel like to lose a sibling. Well, let's get close, Meisner says. Ever lose a parent? Dear friend? Was it pretty miserable? Alright, THINK about that and say the lines.

For my 6th kyu test I have to perform hensoijutsu as Yado Nashi, or a homeless man. I originally thought to do research, and that is a good idea for the facts - where I live, how I got there, etc. For my actual preparation, though, I have to key in on emotion - hopelessness, or determination depending on my character. I have to call up something that harbors the emotion of the character as well as remember the facts. It isn't like the facts will be more true with the right emotion, but they sure will be more believable.

Going to the decision maker matters for the IT Pros and Developers too

When I was in sales, one of the tenants of making a close was driving to the decision maker.  Anyone who stands in the way is a "gatekeeper" and is just there to protect the decision maker, like the offensive line in football.  Jeke past the tackle!  Watch out for the tight end!

The reason for focusing on the decision maker is to reduce the number of times that you have to hear the organizational customer say "no".  You have to wait througn 7 nos to get a sale as it is, you don't want to hear "But now you have to talk with Mr. Manager."  You want a check written after you hear yes.  Therefore, get to the decision maker.  There are a bevy of methods to use to get past gatekeepers, and young sales trainees - such as myself years ago - learn them by heart.

What I am learning, as I delve deeper into the Software Architecture role, is that getting to the decision maker is just as important for the professional IT consultant.  There are just as many gatekeepers in the IT department of midsized companies as there are in the purchasing department.  These are even more subtle, too, if that is possible; they might even think (incorrectly) that they are the decision maker, but they are not.  Whe you are consulting for a company, and have the opportunity to garner additional project hours by solving a new problem, you are often the only person in the building who can bring the new sale to a close.

The problem is one of feifdoms.  Someone in IT designs a network, or manages a server, or writes a key piece of software, or configures some middleware, and they think that they own it.  They do all the work, they make all of the key decisions, so they must own it, right?  Well, no.  Especially when a decision impacts something else in the company.  Now, if they do something on company time and get overruled, it's not a big problem.  They grumble, turn it off or whatever, and all is forgotten.

But if you, as a consultant, do it on their OK and it gets overruled, you might not get paid.

Suddenly, getting to the decision maker seems like a really good idea, especially when pitching a new piece of work.  Here are a few tips from my experience to help you get past the IT Manager of the Fiefdom, and to the person who writes the checks.

  1. First, know who writes those checks.  It is tough to find the real decision maker in some firms.  Often, the functional decision maker is the IT manager, but they have a higher power in the CIO or CEO or owner who might know little about technology.  It is essential to get this person's buy in.
  2. Remember that gatekeepers are your friend.  Don't tick off the 'owner' of the target system just because they don't write the check.  Your case is so much better off if both you and the system manager go to the decision maker.
  3. Have an elevator message ready.  Often, you will find yourself at the coffee shop or wherever with the decision maker, and might be able to catch him or her for a minute before or after.  Have a compelling 30 second pitch ready that describes what you are trying to do.
  4. Remember to listen.  Don't just talk.  Sometimes no is no.  Sometimes you have a bad idea, and that is why you are being blown off.  Sometimes you are explaining it poorly, and that's why you can't make the close.  Listen to the feedback.

Finding continuing work as a consultant often requires sales measures.  You can depend on a recruiter to get you into a client, but you often have to keep yourself there.  Having a plan to get tot he decision maker will make that process smoother. 

Strength

By far, the easiest way to defeat me in randori is to wear me out. I am 36, 230 pounds, and don't work out enough. Lie on me and make me work - I'll be wiped in no time.

Recently though I have been training with the kuji-in. Funny, that. It seems to work. The Bansenshukai curriculum has one of the nine ninja mudra for each of the nine kyu. The first mudra, for ninth kyu, is Rin or Strength. Every day, during my meditation, I have been focusing on those times when I have found extraordinary inner strength. Once, I stayed up for a very long time when I had a project due and Adam was sick. In a less poignant example, I recently ran a long time on the treadmill, finding some inner endurance. I lasted a long time in one particular randori, and can recall that.

All of this is done while making the Rin mudru, which is hands together, fingers intertwined. The middle finders are raised and touching. what this allows me to do is use the unusual muscle memory to recall all of that hours of meditation in a moment's notice. Say, for instance, right before a long randori match.

It might sound dorky but it works. Just like sitting in Seiza might make you think about class, the mudra recalls the topic of the meditation. I was impressed. I am totally not into mystical stuff (ask anyone about me lack of respect for religion) but when something works it works. The tie between muscle memory and long term memory is well documented.

I like it a lot. This is where the 'magic' of the ninja comes in.

More at Wikipedia.

S. U. R. V. I. V. A. L

I have been reading The Special Forces Guide to Escape and Evasion by Will Fowler to kinda formulate a strategy for Intonjutsu in my mind. We study element driven styles of escape and evasion in the club (like Katonjutsu, using fire to mask scent or make a barrier) but I like the forest view once in a while, so I read overview books on contemporary Ninjutsu topics.

I learned something very cool in the Zanson area in the first chapter, though. I like acronyms in emergency situations - when you can't remember much else, you can often remember cool acronyms. Here is one for situations in which Zanson is important: SURVIVAL.

Size up...
... the situation
... the surroundings
... your physical condition
... your equipment

Use all senses
Remember your location
Vanquish fear
Improvise
Value living
Act like the natives
Live by your wits

Now, I think that is good anywhere. If you are in the desert being chased by a band of roving Mujahideen or in the mall during a fire, this is a good set of steps to keep yourself on track. The first and most important thing that most people always forget to do in any emergency is to take a second and Size up the situation. Stop. Look around. What is REALLY happening? Where are you specifically AND in general. Can your environment help you? Are you hurt? Are any of your wards hurt? What do you have with you? Would it be better in your hand right now, or stowed?

A better part of Ninjutsu, as I have posted before, is preparedness. While at the time I was talking gear, it is important to be prepared mentally. None of us know how we will respond in an emergency until one happens, so it is a good idea to have a Contingency Plan of Action for most major types of emergencies, and starting with SURVIVAL isn't a bad bet.

Killing

I have been reading On Killing by Lt. Col. Dave Grossman, and it has me thinking about the reality of the martial arts. War is war, and defeating the enemy is just another word for killing them. Lt. Col. Grossman puts a lot of emphasis on the distance factor (it being a lot easier to kill with bomber than a knife) and it came to me that a lot of Ninjutsu is about killing at VERY close range.

Lets face facts. Ninjutsu is not a movement study. It is about completing an objective, no matter what the odds. If you are training any other way, you might want to ask yourself why you are into Ninjutsu and not Aikido or tai-chi if you like the movement, or judo or karate if you like competition aspect. Nonetheless I have to wonder how many of us could stab an adversary with a knife if the situation warranted. Many of my friends in the club are military and police - they are studying to improve their chances of survival. They might have to complete that thrust we all learn in tantojutsu.

Could you? I don't know if I could.

The psychological aspects of Ninjutsu are shrouded in a combination of the general fear of discussion of Ninjutsu and the "you'll learn that later' part of the art. Fact is, I think a decent psychoanalyst could have a field day with most of us, starting with Hatsumi himself. Studying a combat martial art in this day and age, when you aren't actually planning on any combat is, well, strange.

So why do we? Preparation? Are we getting ready for when martial law is declared? Is it really just self defense? I have no idea. But I have a sneaking suspicion that 1) there is a lot to learn form this art without being consumed with the concept of death and 2) not many of us are gonna find out and that is a good thing.

Read On Killing. It will get you thinking.

Training

Shidoshi posted recently about taking change of one's own training. I don't think I could agree with him more if I tried but only now, after almost a year in, am I starting to get more insight into that principle.

You see, I am not of the warrior caste, as I think I have posted about before. I really have to work at this stuff. None of it comes naturally. I usually get my self up to 80% and them let my natural talent carry me the rest of the 20%. In this, I can't do that. I don't have any natural skill. I have to train all the way to 100%. I have never had to do that before in anything I have done.

So I need a new way to work.

In my particular school, there is a lot of stuff to learn. A LOT. Most than most ninjutsu schools that I have seen the kyu sheets for. Ok, more than all of them. Put together. For my 7th kyu test, I have 29 individual testable points. For the taijutsu parts, I have to know henka and counters, too. Ouch.

Shidoshi says that you have to do each individual movement 100 times with a compliant uke before the muscle memory even starts to think about kicking in. After that, you need to take it to randori and work it there 100 more times. Ok, I think I agree. I am going to formalize it a little bit, and actually plan my training.

For my 7th kyu exam, I am going to actually make a training chart, and track how often I train on each individual item. Everything - from the side roll to the jujutsu kata items. Some I can train alone, most I need an uke for, but that's what open mat is for. AND I will go to class as well.

What I need now is to revise my vision on why I am training. Fact is, I am training like I will use it. Fact is, I probably won't use it. I might once or twice (Aikido has saved my ass twice) but probably not much more than that. I need to now train to get good at it - becasue it is going to be really good for me to get good at something that I have a hard time with.

That might not be enough though. I am a very competition driving individual, though I don't pretend like I am. Takamatsu-sensei said something that matters, though.

The way of the martial artist is the way of enduring, surviving and prevailing over all that would destroy him. More than delivering strikes and slashes, and deeper in significance than the simple outwitting of an enemy, Ninpo is the way of attaining that which we need while making the world a better place. The skill of the Ninja is the art of winning.

Yes. Yes indeed. That's what I am training for - winning. Doesn't matter if it is in the boardroom or a brawl, winning is winning. That's what I am after.

History

If you hang out at forums like Martial Talk, you will discover that there is a fair amount of discussion regarding the history of Ninjutsu. Generally speaking, there is no real record of ninja before about 1956, and Takamatsu more or less defined the genre. The common belief is that he just created it, and Hatsumi, with his marketing brilliance, has expanded it. The 900 year history is an urban legend.
I say this: So what?

What I, you, my training partners and the Marines are looking for is a fighting system that works. If Takamatsu invented one and it works, who cares? Ueshiba invented Aikido and it works for what it is designed for. Kano invented Judo and it works very nicely too.

I think the problem lies in the same as the one of religion. If something that God or Jesus said is proved to be irrevocably false (like absolute proof that Mary wasn't a virgin, for instance) then large pillars of Christianity fall. If the premise that Hatsumi isn't teaching the art of 33 people before him falls, then again, the Bujinkan will lose a fair amount of identity.

And no one likes to see that.

Don't worry about identity. the implication of that is that you have to be willing to waste a little time studying with someone that turns out to be not what you want then leave. But if that means you find the teacher that you do want, then it was well worth the effort.

That's what it all comes down to - learning what you want to learn. The only kicker is this - be realistic. If you are studying ninjutsu and learning to break bones, don't think you can take your skills to MMA - they don't like broken bones there. If you are studying Aikido and think you are going to go fight on the streets of New York you might want ot reconsider. The art depends heavily on a trained uke.

So - conclusion. 1) Don't worry about history, worry about now. 2) Find an art that works for you, taught by a teacher that works for you. 3) be realistic. Words to train by. Have a nice night.

Why I build systems using Microsoft

I have a few very high profile (read: TV ads and NYSE listings) clients who are on me about solving their problems using Microsoft.  "LAMP ( Linux Apache MySql PHP ) is cheaper!", they say.

Well, they are wrong.  You have to consider cost of ownership, and that includes a lot of inputs.  This, which I have been following for years now, is just the latest.

PHP Security Team Member Resigns

Fact is, this story at Microsoft would have been reported by Brian Williams, probably from Seattle.  As it is, most everyone says 'What is PHP?' even if they do hear about the story.  They don't realize that many many high profile sites use this toy for an enterprise language.

You know, this is a big deal.  I'll get the rest of the information that makes this blog interesting and add it later.

One thing - this is not a condemnation of open source.  I love it, I participate, and I use it a lot.  Don't use it for enterprise applications unless you know exactly what you are doing.

Bill Sempf

Husband. Father. Pentester. Secure software composer. Brewer. Lockpicker. Ninja. Insurrectionist. Lumberjack. All words that have been used to describe me recently. I help people write more secure software.

PageList

profile for Bill Sempf on Stack Exchange, a network of free, community-driven Q&A sites

MonthList