System.DirectoryServices.Protocols.LdapException:LDAP服务器在DMZ服务器中不可用

时间:2018-03-22 18:44:33

标签: c# ldap dmz

我使用下面的代码,它在我的本地工作。但它不适用于DMZ服务器。

public string GetEmailByEmployeeId(string empID)
{
try
{
    using (HostingEnvironment.Impersonate())
    {
        using (PrincipalContext adAuth = new PrincipalContext(ContextType.Domain, this.ADDomain))
        {
            UserPrincipal searchTemplate = new UserPrincipal(adAuth);
            searchTemplate.EmployeeId = empID;
            PrincipalSearcher ps = new PrincipalSearcher(searchTemplate);
            UserPrincipal user = (UserPrincipal)ps.FindOne();
            if (user != null)
            {
                return "Email: " + user.EmailAddress;
            }
            else
            {
                return "No Records Found";
            }
        };
    }
}
catch (Exception e)
{
    return e.ToString();
}
}

获取以下错误:" System.DirectoryServices.AccountManagement.PrincipalServerDownException:无法联系服务器。 ---> System.DirectoryServices.Protocols.LdapException:LDAP服务器不可用。

0 个答案:

没有答案