3
votes

I am creating a form within InfoPath which is to be integrated into a SharePoint 2007 Portal. Within this form there will be a textfield into which a user can enter the Name of a Person.

How can I validate whether this Person exists or not?

Instead of validating the user, is there a way to fill a dropdown List with all usernames of the portal? (which of cause would be users from the Active Directory)

6

6 Answers

1
votes

I haven't done this specifically, so there may be a better way, but I've been pulling a lot of data out of SharePoint and into an InfoPath Form (deployed to a SharePoint forms library and accessible through SharePoint Forms Service with MOSS Enterprise) and also going the other way using the SharePoint web services - very quick to use, and the person web service is right there.

1
votes

Have you tried looking at the Contact Selector (an ActiveX control). Here is a MSDN-article describing how to add it as a control in InfoPath and this one describes how to make it work.

I have been using it in the majority of my infopath projects and it works flawlessly - also for browser-enabled forms.

0
votes

When doing something similar in an ASP.NET application, I've used the Sharepoint search and searched the "People" Scope for the specific user. You can also search across profile information so you can pull back everyone with a certain Job Title, or in a specific Department.

0
votes

I don't validate a person's existance, but I do determine a person's full name using their login and SharePoint. You should be able to modify this code for your purposes, it is below. For it to function you need a data connection in your InfoPath document called GetUsersFromSP. Configured as follows:


string ADName = System.Environment.UserName;
        IXMLDOMDocument3 UserQuery = (IXMLDOMDocument3)thisXDocument.GetDOM("GetUsersFromSP");
        UserQuery.setProperty("SelectionNamespaces",
            "xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\" " +
            "xmlns:tns=\"http://schemas.microsoft.com/sharepoint/soap/directory/\"");

        ((WebServiceAdapterObject)thisXDocument.DataAdapters["GetUsersFromSP"]).Query();

        IXMLDOMNode Users = UserQuery.selectSingleNode("//dfs:myFields/dfs:dataFields/tns:GetUserCollectionFromSiteResponse/tns:GetUserCollectionFromSiteResult/tns:GetUserCollectionFromSite/tns:Users");

        foreach (IXMLDOMNode current in Users.selectNodes("tns:User"))
        {
            string Login = current.attributes.getNamedItem("LoginName").text;

            Login = Login.ToUpper();
            if (Login.EndsWith(ADName.ToUpper()))
            {
                thisXDocument.DOM.selectSingleNode("my:root/my:config/my:User").text = current.attributes.getNamedItem("Name").text;
                break;
            }
        }
0
votes

Use this control: http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx

Or if you want to build your own validator, you'll need to query the SharePoint profile database. I'd recommend this over querying AD directly. There's lots of articles online about working with the profile database.

0
votes

Have a look at this Link, it explains how to populate a dropdown with the SharePoint Users

http://blueinfopath.blogspot.com/2008/10/how-to-populate-list-with-sharepoint.html

I you want to validate, - Make a textbox - Add a Button, name it ValidateUser - Create a Receive Connection to the ...... - Att Rules to the ValidateUser - Add the textbox to the field AccountName in the Secondary Datasource - Execute the receive connection - Get the value of the field Value with filter Name="PreferredName"

This work for Infopath Form Services Test it and enter the UserLogin into the textbox and click on the Validate Button

Frederik