简体   繁体   中英

How can I validate within an InfoPath form whether a user exists within a SharePoint Portal?

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)

我没有专门做过这个,所以可能有更好的方法,但我已经从SharePoint中提取了大量数据并转换为InfoPath表单(部署到SharePoint表单库,可以通过带有MOSS Enterprise的SharePoint Forms Service访问)并且还使用SharePoint Web服务以另一种方式 - 使用非常快,并且人员Web服务就在那里。

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.

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.

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;
            }
        }

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM