Here's a quick example:
public ProfileBase[] GetUserProfilesByWordByProfileManager(string searchByValue)
{
ProfileBase[] profileBase = null;
try
{
var serviceContext = SPServiceContext.Current;
var userProfileManager = new UserProfileManager(serviceContext);
profileBase = userProfileManager.Search(searchByValue);
return profileBase;
}
catch (Exception innerException)
{
throw innerException;
}
}
You can always cast the ProfileBase to a UserProfile:
UserProfile userProfile = (UserProfile)currentPB;
Good Luck ;)
Boas! O que passas no value? Podes colocar um exemplo? Abraço =)
ReplyDeleteViva. Passas, por exemplo, "Pedro" se quiseres pesquisar por user profiles que tenham o nome Pedro.
ReplyDeleteok, estava a pensar se não seria por exemplo uma expressão...
ReplyDeleteThe searchByValue is case sensitive, ie "mis" does not return words start with "Mis", is there any way to get the wild card search working? "*mis*"
ReplyDeleteHi Wang Hao, sorry for the late response. I didn't need that kind of search, since I searched for the Profile of the current user ;)
ReplyDeleteHave you tried the ProfileSearchManager Class:
http://msdn.microsoft.com/en-us/library/ee582195.aspx
?