Active Directory ユーザー名を取得するために、asp.net mvc Web アプリケーション内に次のコードがあります。
public List<DomainContext> GetADUsers(string term=null)
{
List<DomainContext> results = new List<DomainContext>();
using (var context = new PrincipalContext(ContextType.Domain, "v800047"))
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
上記は開発環境でうまく機能していましたが、コードをステージング サーバーに移動し、それに応じて AdServerName を変更すると、次のエラーが発生します。
Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error
and where it originated in the code.
Exception Details: System.DirectoryServices.DirectoryServicesCOMException:
Logon failure: unknown user name or bad password.