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.

Infopath and Active Directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smonczka - 11 Aug 2005 22:27 GMT
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
agni - 12 Aug 2005 00:52 GMT
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 www.autonomysystems.com premium downloads section.

-Agni

> 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
JNL - 12 Aug 2005 18:02 GMT
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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/
ipsdkDeployURNFormToSharePoint_HV01086376.asp

Understanding Fully Trusted Forms
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/
ipsdkUnderstandingFullyTrustedForms.asp

Using the Form Registration Tool
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/
ipsdkUsingTheFormRegistrationTool.asp

I hope this helps!

Scott L. Heim
Microsoft Developer Support
smonczka - 15 Aug 2005 21:48 GMT
Scott Thank you for the references on Trusted forms.  They were a big
help.

Steve
smonczka - 15 Aug 2005 21:48 GMT
Scott Thank you for the references on Trusted forms.  They were a big
help.

Steve
smonczka - 15 Aug 2005 21:48 GMT
Scott Thank you for the references on Trusted forms.  They were a big
help.

Steve
smonczka - 15 Aug 2005 21:48 GMT
Scott Thank you for the references on Trusted forms.  They were a big
help.

Steve
 
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.