错误System.DirectoryServices.DirectoryServicesCOMException(0x8007203B):发生本地错误

时间:2012-12-03 11:25:52

标签: asp.net iis-7

我使用以下代码验证LDAP中的用户和密码:

        bool authentic = false;

        string ip_server = "10.53.41.21";
        string userName = "CN=test,N=Users,DC=user,DC=domain,DC=COM";
        string password = "something";
        try
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://" + ip_server, userName, password);
            //   entry.
            object nativeObject = entry.NativeObject;
            authentic = true;
        }
        catch (DirectoryServicesCOMException) { }
        return authentic;

它在本地和IIS 6.0上运行正常。但是在IIS 7.0上运行时会出错:

System.DirectoryServices.DirectoryServicesCOMException (0x8007203B): A local error has occurred.

   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_NativeObject()

如何解决这个问题?

谢谢!

1 个答案:

答案 0 :(得分:1)

您正在传递用户名的distinguishedName属性,其格式应为以下格式:domain\username

相关问题