Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
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 https://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
Comments
- Anonymous
September 28, 2006
System.Environment.UserName requires Full trust, or more precisely a
permission that only Full trust forms would get.
Note that System.Environment.UserName will not return the real WSS user
name, which I assume your code actually needs. Instead, we recommend using
the InfoPath OM to get the user name. - Anonymous
September 28, 2006
System.Environment.UserName requires Full trust, or more precisely a
permission that only Full trust forms would get.
Note that System.Environment.UserName will not return the real WSS user
name, which I assume your code actually needs. Instead, we recommend using
the InfoPath OM to get the user name. - Anonymous
November 01, 2006
The comment has been removed - Anonymous
December 08, 2006
Hum- this post is great - just what I need to do. But... I need to do it using VB.NET - the text above seem to imply that there is a sample in VB, but from I don't see it. It seems to be written in C#. Does the VB sample exist anywhere else? thanks!