How can I grab the current Windows login?

T

tommcd24

I want to be able to grab the windows login for the current user when a
form is opened so that I can pre-populate a couple of basic fields
(Name, Dept., Email).

Is there a way to do this?
 
A

Ameet Phadnis(e Tek Global Inc.)

You have to do it through script. I think the JScript is something like this -
var networkuser = new ActiveXObject("WScript.Network");

// Use networkuser.UserName to get login name

You could also use Visual Studio.NET for InfoPath forms and write .NET code.
 
T

tommcd24

Thanks for the reply Ameet.
I'm new to InfoPath (started with it on Monday...) it was my
understanding that InfoPath only allows JavaScript & VBScript. Do I
need to do anything special to use .NET code?
Also, is the variable automatically exposed to the form or do I need to
write code to copy the value from the variable to the proper node?
 
A

Ameet Phadnis(e Tek Global Inc.)

It does allow you to code in VB.NET also. You can download the tools for it
at this location
http://www.microsoft.com/downloads/...57-e115-4cac-9986-a712e22879bb&displaylang=en

Also, you have to write the code to put the value in some node. When you
submit the form the variable won't be available because the form is being
submitted as XML file. So, you need to use some expression as -
XDocument.DOM.selectSingleNode( "<Your node reference>" ).nodeTypedValue
 
T

tommcd24

I tried the ... new ActiveXObject("WScript.Network"); code you
suggested but I get an error indicating "Automation server can't create
object" on that line.

Any suggestions on what might be the problem?
 
A

Ameet Phadnis(e Tek Global Inc.)

It might be security policy issue. I ran into similar problem last year. I
don't remember now what I did to make it work. But eventually I moved that
form to use .NET code.

Let me try to remember it and I will post a reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top