Я хочу иметь возможность получить идентификатор пользователя пользователя в Active Directory, используя отображаемое имя этого пользователя. Отображаемое имя получается из базы данных и хранилось во время этого сеанса пользователя, используя следующий код для получения отображаемого имени:
using System.DirectoryServices.AccountManagement;
private string GetDisplayName()
{
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find currently logged in user
UserPrincipal user = UserPrincipal.Current;
return user.DisplayName;
}
На этот раз мне нужен метод с именем GetUserIdFromDisplayName()
, который возвращает имя входа в Active Directory. Любые идеи?