Getting users Username - InfoPath Dev
in

InfoPath Dev

Getting users Username

Last post 02-23-2008 09:27 AM by dpsol. 25 replies.
Page 1 of 2 (26 items) 1 2 Next >
Sort Posts: Previous Next
  • 09-09-2005 07:36 AM

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47

    Getting users Username

    I've been searching through the threads and from what I have read it seems that you can get the current users username.

    How is this done? Jscript? VBscript?

    I don't have the .NET framework and have a feeling that this will affect whether or not i can access the users.

    How would I use system.environment.username

  • 09-09-2005 09:44 AM In reply to

    You need to build an ADService webservice and use that to get the User name.
    There is another way to get the UserName using an ActiveX component, but that needs your solution to be a FullTust solution.
    http://www.infopathdev.com/webstore/detail.aspx?itemid=18

    There is an ADService available at this site, that you can use to get user Details from ADService.

    Agni
    InfoPath Dev India
  • 09-09-2005 04:22 PM In reply to

    Do a search on "current user". Also check outhttp://www.infopathdev.com/forums/topic.asp?TOPIC_ID=699
    Jason
    http://www.k2distillery.com/
  • 09-13-2005 11:05 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    My situation seems a bit different.
    I don't have the .NET framework and I am not using sharepoint.

    I am publishing the forms to our intranet. We have created an ASP (not .NET) app that lists links to the forms and users have access to forms on a departmental basis.

    I want to access the persons username if possible without a web service, sharepoint or the .NET framework for validation reasons.

    I'm getting the feeling this may not be possible.
  • 09-13-2005 11:46 AM In reply to

    In the link above, I referenced some ways to get the current user name with script, the second one mentions using ActiveX.

    "2 - Use ActiveX to get the current user name (discussed on this forum)."

    Read this as well -http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=173
    Jason
    http://www.k2distillery.com/
  • 09-13-2005 12:01 PM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    ok got the ActiveX example to get the username.

    Is there anyway to get rid of the warning saying:

    "An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?"

    it could scare some of my users
  • 09-13-2005 12:10 PM In reply to

    Was waiting for that question :-)

    That was one of the reasons why I did not use it because of that prompt but I had the ability to using ASP.NET to get the current user.

    I believe you can get rid of it by messing around with IE security options. InfoPath is built on IE security model. I am not an expert on this topic. If you have the InfoPath form in Design Mode go to Tools >> Options >> press the Internet Options button and you will now see the typical IE properties window >> go to the security tab >> press the Custom Level... button.

    I do not know the correct setting off hand. Try some searches on ActiveX and see if anyone else has posted a solution.
    Jason
    http://www.k2distillery.com/
  • 09-13-2005 12:13 PM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    Thanks VT.

    I had tried the activex approach before but i didn't seem to work.

    may have been my coding.
  • 09-13-2005 12:41 PM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    can this same thing be done in vbscript?
  • 09-13-2005 01:05 PM In reply to

    Yes it can, one of my clients wanted everything in VBScript:

    Dim wsh
    Set wsh = CreateObject("WScript.Network")
    XDocument.UI.Alert(wsh.UserName)
    Jason
    http://www.k2distillery.com/
  • 09-13-2005 01:18 PM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    I'm trying to get the current users username during the OnLoad Event but the vbscript is thowing an error saying:

    ActiveX component can't create object: 'WScript.Network'

    Dim wsh
    Set wsh = CreateObject("WScript.Network")
    un = wsh.UserName
    XDocument.DOM.selectSingleNode("//my:myFields/my:field14").text = un

    any ideas?
  • 09-13-2005 01:27 PM In reply to

    Bummer that worked for me when I threw that into an OnLoad event.

    This one also works for me...after that I am not sure I know what else will work.

    Dim sUserName
    sUserName = CreateObject("Wscript.Shell").Environment("Process").Item("UserName")
    XDocument.UI.Alert(sUserName)
    Jason
    http://www.k2distillery.com/
  • 09-13-2005 01:28 PM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    if the jscript works should the vbscript work?

    do i need to have anything special installed for the vb version to work?
  • 09-13-2005 02:07 PM In reply to

    I would think if the jscript works, then the vbscript would work.

    What is the exact error message that you are getting? Does it have anything do with ActiveX not being allowed to run in IE on your machine as I described above?
    Jason
    http://www.k2distillery.com/
  • 09-14-2005 05:47 AM In reply to

    • drobins
    • Top 500 Contributor
    • Joined on 08-17-2005
    • Canada
    • Posts 47
    This is the error i am getting
    A runtime error has occured
    Do you want to debug?

    ActiveX component can't create object: 'WScript.Network'
    file: script.vbs
    line: 23

    how is it that i can create the object in jscript but not vb?
Page 1 of 2 (26 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.