How to Populate Current User in Form Without Needing a Code Signing Certificate

Folks,

On my Blog I have two code samples that talk about pulling the Current User information based on the user's authentication to Active Directory and populating it into a form.   One sample uses JScript and the other uses VB.Net.    The JScript sample requires that the solution be signed with a Level 2 code signing certificate.    Alternatively you can deploy the solution as an MSI using a tool in the Resource Kit, but that turns out to be somewhat problematic over time (breaks slick deployment and update model).   I'm not sure about the second VB.Net sample, I haven't tested it myself and so not sure 100% how it works and what might be needed to have that code run.   I do know of another code sample that uses C# to do the same thing, and I have tested it and it works without requiring a signing cert.    That code and the walkthough on how to use it is here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_tr/html/odc_INF_Lab_15.asp.    For the benefit of the Blog, the actual code you need is here:

// store an XMLDOM node as a local variable
IXMLDOMNode nodeEmployee =
thisXDocument.DOM.selectSingleNode("my:myFields/my:employee");
if(nodeEmployee != null){
      if(nodeEmployee.text == ""){
         // if the employee name is blank when we load the form,
         // populate the employee node with the current user name
nodeEmployee.text = System.Environment.UserName;
}
}

Pretty simple, huh?

Tim