Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

How to know who fill the form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
S.Dayot - 28 Jul 2005 11:00 GMT
Hello I want to include in my form the name of the person who will fill the
form. But I don't know how to do it maybe use VBscript to have the username
of ActiveDirectory account if you can't help me please.
Scott L. Heim [MSFT] - 28 Jul 2005 13:40 GMT
Hi,

If you have created an InfoPath solution using Visual Studio.NET then you
can use the "Environment.UserName" variable. If you simply need to be able
to query Active Directory, then here is a sample procedure to do so:

** NOTE: This uses VBScript and will require your form to be fully trusted.

Function GetADInfo
    Dim objADSystemInfo
    Dim objUser
    Dim objManager
    Dim strLogin
    Dim strMail
    Dim strAlias
    Dim objGroup
    Dim strGroups
   
    Set objADSystemInfo = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" + objADSystemInfo.UserName)
    Set objManager = GetObject("LDAP://" + objUser.Get("manager"))
   
    'Get all the groups the user is enrolled in
    'For Each objGroup In objUser.Groups
    '    strGroups = strGroups & vbcrlf & objGroup.name
    'Next
   
    strLogin = objUser.Get("cn")
    strMail = objUser.Get("mail")
    strAlias = left(strMail, instr(1, strMail, "@")-1)
   
    'XDocument.UI.Alert "User: " & strLogin & vbcrlf & "Alias: " & strAlias &
vbcrlf & "Manager: " & objManager.Get("name") & _
    'vbcrlf & "E-mail: " & strMail
    GetADInfo = strAlias
End Function

What you can now do is use code similar to the following to populate a text
box on your form when it opens - so you would have code like this on the
Load event of the form:

    Dim objUser
    Set objUser = XDocument.DOM.selectSingleNode("//my:myFields/my:field1")
   
    If objUser.Text = "" Then
        objUser.Text = GetADInfo
    End If

Lastly, if you cannot have a fully trusted form then your last resort would
be to create a "WhoAmI" web service to get the user name - you can search
this forum for more information on this option.

I hope one of these is of benefit for you! :-)

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
Radovan - 08 Aug 2005 14:01 GMT
Try this:

var oNet = new ActiveXObject("Wscript.Network");
sUserID = oNet.UserName;

> Hi,
>
[quoted text clipped - 54 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
Patrick Halstead [InfoPath MVP] - 09 Aug 2005 07:02 GMT
The problem with JScript is that it requires Full Trust to create the
ActiveXObject. Why bother?
You can use C# and System.UserName, or better yet, create an Active
Directory web service (like the one we sell for a measly $19.95 at
http://www.infopathdev.com/webstore/detail.aspx?itemid=18) to return the
data for you. That way, you can remain Domain Trust which is much less of a
pain.

Cheers,
Patrick Halstead
http://www.infopathdev.com/

> Try this:
>
[quoted text clipped - 33 lines]
> >
> > 'XDocument.UI.Alert "User: " & strLogin & vbcrlf & "Alias: " & strAlias
&
> > vbcrlf & "Manager: " & objManager.Get("name") & _
> > 'vbcrlf & "E-mail: " & strMail
[quoted text clipped - 22 lines]
> >
> > This posting is provided "AS IS" with no warranties, and confers no rights
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.