pGina.Plugin.Ldap.LdapServer.Bind C# (CSharp) Метод

Bind() публичный Метод

Tries to bind to the server anonymously. Throws LdapException if the bind fails.
public Bind ( ) : void
Результат void
        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;
            }
        }

Same methods

LdapServer::Bind ( NetworkCredential creds ) : void

Usage Example

Пример #1
0
 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"));
         }
     );
 }
All Usage Examples Of pGina.Plugin.Ldap.LdapServer::Bind