public void Bind() { if (m_conn == null) throw new LdapException("Bind attempted when server is not connected."); m_logger.DebugFormat("Attempting anonymous bind", m_conn.SessionOptions.HostName); m_conn.AuthType = AuthType.Anonymous; m_conn.Credential = null; try { m_conn.Bind(); m_logger.DebugFormat("Successful bind to {0}", m_conn.SessionOptions.HostName); } catch (LdapException e) { m_logger.ErrorFormat("LdapException: {0} {1}", e.Message, e.ServerErrorMessage); throw e; } catch (InvalidOperationException e) { // This shouldn't happen, but log it and re-throw m_logger.ErrorFormat("InvalidOperationException: {0}", e.Message); throw e; } }
public void TestConnect3() { LdapServer serv = new LdapServer(new string[]{host}, port, false, false, null); serv.Connect(10); Assert.Throws<LdapException>(delegate { serv.Bind(new NetworkCredential("cn=Manager,dc=example,dc=com", "seret")); } ); }