userName() blank - InfoPath Dev
in

InfoPath Dev

userName() blank

Last post 02-11-2008 01:15 PM by davidair. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 02-10-2008 02:46 PM

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    userName() blank

    Hi

    The setup:

    • InfoPath form in forms services.
    • WSS site using Forms Auth with a custom provider
    • Web service to expose user details

    When my form loads I want to pre-populate some fields with the current user details.  In the form load rules I query the web service and use the userName() to pass as the single parameter to the GetUserDetails() method. 

    If I preview in InfoPath the web service is passed the windows account I'm logged in with. When I debug this on the published form the user name parameter comes through as blank. 

    I'm sure this used to work a while ago.  I'm not sure what might have changed but I'm thinking it's something to do with the authentication setup of WSS rather than the form.

    Does Forms Services need to use the same auth provider as the site collection maybe?

    Any ideas anyone?

     

    Thanks 

     

     

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-10-2008 02:53 PM In reply to

    Hi Jonesie and welcome!

    I'm assuming you have a UDC file set up for the Web Service that your browser form is using. Please check that proxy service is set to false.

    Patrick Halstead
    Project Manager at Qdabra
  • 02-10-2008 03:34 PM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Hi

    I don't have a UDC setup for this form yet as I found them a PITA to create.  Your tools might make this easier tho. 

    I have a feeling I might have fiddled with proxy settings also... will check that.

    Cheers

     

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-11-2008 12:12 AM In reply to

    You will definitely need a UDC. Please download the UDC Editor and tell us what you think.

    Patrick Halstead
    Project Manager at Qdabra
  • 02-11-2008 08:01 AM In reply to

    Jonesie,

    If you're not afraid of writing a little code, you can set the field's value with one line of C# in the form's onload event:

    MainDataSource.CreateNavigator().SelectSingleNode("//[xpath expression here]").SetValue(Application.User.UserName);

    This is what I do, but with the code behind the form, it requires a little more work to publish the form template.
     

  • 02-11-2008 11:28 AM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    I tried it and it blew up when I tried to view a UDC or create a new one.  Needs a bit more work I think...

     

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-11-2008 11:32 AM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Hi

    It's not that I'm afraid of coding but a) it will make the process require a developer which we are trying to avoid and b) InfoPath is the worst development tool imaginable. The UI is so incredibly poor it's only a passable forms editor. Who ever thought of allowing managed code in these things should be shot!

    Cheers 

     

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-11-2008 11:33 AM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Oh, and I dont think this will work as userName() is returning a blank string in web mode so Application.User.UserName will probably be the same. 

    Instead I will pass a parameter from the web part that launches the form. Ah, but crap, that wont work either as I need to write code to do that.

    Cheers

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-11-2008 12:25 PM In reply to

    Hey Peter.

    Here is an Active Directory Web Part that can be used codelessly.  One advantage it has is getting the Domain Account the user is using rather than the local user like UserName() does, if you have remote users.

    http://www.qdabra.com/en/products/ADWebService.aspx

    I believe there is also a Sharepoint 2007 web service that can be used, but it will not retrieve as much information as Active Directory will.

    Just an FYI for you if it helps.

  • 02-11-2008 12:31 PM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Thanks, but we are using a custom provider - which I think is the source of the problems.

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-11-2008 01:15 PM In reply to

    I tried to see how userName is implemented via reflector but it seems like the most interesting bits are obfuscated :)

    Nonetheless, I was able to dig out this:

    return SPControl.GetContextWeb(HttpContext.Current).CurrentUser;
     

    This may give you the idea of what is going on... also, like you have mentioned, you might want to make sure that both Forms Services and your site use the same authentication scheme. I believe Forms Services run in a different vdir (namely, _layouts) so you may consider putting Anonymous/Forms on it as well.

    Good luck!

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.