views:

2232

answers:

7

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)

+1  A: 

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.

Moo
I found out that I can use the userprofileservice.asmx in order to receive user-specific data, but this is only for the current user. I have not found out how to receive data from different users by using that webservice. Any suggestion?
Marcus
A: 

Did anyone figure out how to do this?

A: 

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.

jwmiller5
+1  A: 

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.

A: 

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;
            }
        }
oillio
A: 

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.

A: 

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