keyongtech


  keyongtech > infopath > 08/2005

 #1  
08-11-05, 10:27 PM
smonczka
Is it posible to pull a users information into an Infopath form from
active directory. If so could you point me in the direction of an KB
that would explain the process?

Thanks for the help,
Steve
 #2  
08-12-05, 12:52 AM
agni
Hi Steve,
You have top either write a webservice to get the information from the
Active Directory or you can write code to get the infomation. But the
writing code will require full trust to your form.

Webservice is the best option for you. There is a Ready to use AD Webservice
to get the user info at http://www.qdabra.com/ premium downloads section.

-Agni

"smonczka" <smonczka> wrote in message
news:5500
[..]
 #3  
08-12-05, 06:02 PM
JNL
Hi Steve I paste you here a previous post of Steve its formaly help me hope
that it would be the same for you.


Yes - the following is sample vbscript:

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

As an example, I have a field on my form (field1) and on the Load event of
the form, I have the following:

Dim objUser
Set objUser = XDocument.DOM.selectSingleNode("//my:myFields/my:field1")

If objUser.Text = "" Then
objUser.Text = GetADInfo
End If

So if field1 is blank, it calls the AD code and populates the text box with
the user's name.

My apologies as I did not intend for this to be confusing. The function
(GetADInfo) is simply pasted into the script editor behind your InfoPath
solution:

- From the Tools menu choose Programming and then select Microsoft Script
Editor
- Scroll to the bottom of all code and paste the function

- The second part of what I provided was merely to describe how that
function could be used. One way I have used this was to place this code:

Dim objUser
Set objUser = XDocument.DOM.selectSingleNode("//my:myFields/my:field1")

If objUser.Text = "" Then
objUser.Text = GetADInfo
End If

In the "Load" event of the form (Tools->Programming->On Load Event.) Keep
in mind, this is just a sample and assumes there is a field on the form
named: field1 that resides in the myFields layer. So this sample code first
checks to see if "field1" is empty and if so calls the GetADInfo function
to populate that field.

There is one additional item I forgot to mention: this code will require
your form to be fully trusted. If you would like to get more information on
fully trusted forms, take a look at the following:

Deploy a Fully Trusted Form to a SharePoint Form Library
[url down]
ipsdkDeployURNFormToSharePoint_HV01086376.asp

Understanding Fully Trusted Forms
[url down]
ipsdkUnderstandingFullyTrustedForms.asp

Using the Form Registration Tool
[url down]
ipsdkUsingTheFormRegistrationTool.asp

I hope this helps!

Scott L. Heim
Microsoft Developer Support
 #4  
08-15-05, 09:48 PM
smonczka
Scott Thank you for the references on Trusted forms. They were a big
help.

Steve
Similar Threads
InfoPath and Active Directory

Hello I want to show Active directory users list in infopath (combo and dropdown), is there any facility for this? Thanks for replay

Infopath and Active Directory??

All, Currently our HR department fills out paperwork for a new user then e-mails it to the HelpDesk which then in return comes to us System Admins. A real pain in the...

How do I connect InfoPath 2003 to Active Directory Data?

How do I connect InfoPath 2003 to Active Directory Data? I can't find any info on it on the net? Anyone have an idea how I can do this? I'm trying to pull job titles out...

How can I connect an InfoPath form to Active Directory?

I was told that InfoPath forms can have fields automatically filled in based on the users login. Is this true? If so, how is this done?

Using Active Directory in InfoPath forms

I am trying to figure out how to use data from the AD in my network to auto-populate InfoPath forms and can't seem to find information to do this. Can anyone help with some...


All times are GMT. The time now is 08:59 PM. | Privacy Policy