|
// Declare return variable. string returnValue = String.Empty;
// Declare ProfileManagementContext. ProfileManagementContext profile;
// Instantiate ProfileManagementContext as an instance of the // Profiles Web service. profile = ProfileManagementContext.Create("http://localhost/ProfilesWebService/ProfilesWebService.asmx");
// Declare and instantiate SearchClause and SearchOptions objects. SearchClause searchClause = null; SearchClause rightClause = null; SearchOptions searchOptions = new SearchOptions();
// Build dataset of searchable entities for a profile. DataSet searchableEntities = profile.GetSearchableEntities();
// Build search clause for the UserObject. SearchClauseFactory factory = profile.GetSearchClauseFactory(searchableEntities, "Address"); searchClause = factory.CreateClause(ExplicitComparisonOperator.Equal, "address_line1", "One Microsoft Way"); rightClause = factory.CreateClause(ExplicitComparisonOperator.Equal, "address_line2", "One Microsoft Way");
searchClause = factory.IntersectClauses(searchClause, rightClause);
// Set number of records to return. searchOptions.NumberOfRecordsToReturn = 10;
// Specify profile properties to return in the search dataset. searchOptions.PropertiesToReturn = "address_id, address_line1, address_line2";
// Execute the search against the Profiles Web service. DataSet searchResults = profile.ExecuteSearch("Address", searchClause, searchOptions); |