似乎每个通过其网络服务与SharePoint交谈的努力都需要一个域用户名。例如:
UserProfileService.GetUserProfileByName(string accountName)
账户名应该是域用户的名称。
If I only got full name (FirstName LastName), is it possible to communicate with SharePoint? Is there any way to convert the full name into domainuser name? Is domainuser name the only way to do it?
提前谢谢。 :)
谢谢您的回答。:)
这个代码看起来像这样:
using System.DirectoryServices;
const string ADPATH = "LDAP://myLDAPserver,validUserforAD";
const string USERNAME = "myDomain\myUserName";
const string PASSWORD = "myPassword";
const string DOMAIN = "myDomain\";
public static DirectoryEntry GetDirectoryObject()
{
DirectoryEntry directoryObject = new DirectoryEntry(ADPATH, USERNAME, PASSWORD, AuthenticationTypes.Secure);
return directoryObject;
}
public string GetUserNameByCompleteName(string completeName)
{
DirectoryEntry adObject = GetDirectoryObject();
//filter based on complete name
DirectorySearcher searcher = new DirectorySearcher(adObject);
searcher.Filter = "displayname=" + completeName;
SearchResult result = searcher.FindOne();
DirectoryEntry userInfo = result.GetDirectoryEntry();
//getting user name
string userName = (string)userInfo.Properties["samaccountname"].Value ?? string.Empty;
userInfo.Close();
adObject.Close();
return DOMAIN + userName;
}