Saltar al contenido

Novell LDAP C # – Novell.Directory.Ldap – ¿Alguien lo ha hecho funcionar?

Verificamos de forma exhaustivamente cada noticias en nuestra página web con la meta de mostrarte siempre información veraz y actual.

Solución:

Vine buscando una solución a un problema similar. Mi comando de vinculación también fallaría al usar el mismo código del sitio web de Novell. La solución que funcionó para mí fue agregar una devolución de llamada de validación de certificado dinámica. Usted puede leer sobre ello aquí.

        // Creating an LdapConnection instance 
        LdapConnection ldapConn = new LdapConnection();

        ldapConn.SecureSocketLayer = true;

        ldapConn.UserDefinedServerCertValidationDelegate += new
                CertificateValidationCallback(MySSLHandler);


        //Connect function will create a socket connection to the server
        ldapConn.Connect(ldapHost, ldapPort);

        //Bind function will Bind the user object Credentials to the Server
        ldapConn.Bind(userDN, userPasswd);

        // Searches in the Marketing container and return all child entries just below this
        //container i.e. Single level search
        LdapSearchResults lsc = ldapConn.Search("ou=users,o=uga",
                           LdapConnection.SCOPE_SUB,
                           "objectClass=*",
                           null,
                           false);

        while (lsc.hasMore())
        
            LdapEntry nextEntry = null;
            try
            
                nextEntry = lsc.next();
            
            catch (LdapException e)
            
                Console.WriteLine("Error: " + e.LdapErrorMessage);
                // Exception is thrown, go for next entry
                continue;
            
            Console.WriteLine("n" + nextEntry.DN);
            LdapAttributeSet attributeSet = nextEntry.getAttributeSet();
            System.Collections.IEnumerator ienum = attributeSet.GetEnumerator();
            while (ienum.MoveNext())
            
                LdapAttribute attribute = (LdapAttribute)ienum.Current;
                string attributeName = attribute.Name;
                string attributeVal = attribute.StringValue;
                Console.WriteLine(attributeName + "value:" + attributeVal);
            
        
        ldapConn.Disconnect();
        Console.ReadKey();
    }

public static bool MySSLHandler(Syscert.X509Certificate certificate,
            int[] certificateErrors)
        

            X509Store store = null;
            X509Stores stores = X509StoreManager.CurrentUser;
            //string input;
            store = stores.TrustedRoot;

            X509Certificate x509 = null;
            X509CertificateCollection coll = new X509CertificateCollection();
            byte[] data = certificate.GetRawCertData();
            if (data != null)
                x509 = new X509Certificate(data);

            return true;
        

Finalmente encontré una manera de hacer que esto funcione.

Primero, estas publicaciones me ayudaron a ir por el camino correcto: http://directoryprogramming.net/forums/thread/788.aspx

En segundo lugar, obtuve una dll compilada de la biblioteca LDAP de Novell y usé Mono.Security.Dll.

La solución:

Agregué esta función al código

// This is the Callback handler - after "Binding" this is called
        public bool MySSLHandler(Syscert.X509Certificate certificate, int[] certificateErrors)
        

            X509Store store = null;
            X509Stores stores = X509StoreManager.LocalMachine;
            store = stores.TrustedRoot;

            //Import the details of the certificate from the server.

            X509Certificate x509 = null;
            X509CertificateCollection coll = new X509CertificateCollection();
            byte[] data = certificate.GetRawCertData();
            if (data != null)
                x509 = new X509Certificate(data);

            //List the details of the Server

            //if (bindCount == 1)
            //

            Response.Write("CERTIFICATE DETAILS: 
"); Response.Write(" Self Signed = " + x509.IsSelfSigned + " X.509 version=" + x509.Version + "
"); Response.Write(" Serial Number: " + CryptoConvert.ToHex(x509.SerialNumber) + "
"); Response.Write(" Issuer Name: " + x509.IssuerName.ToString() + "
"); Response.Write(" Subject Name: " + x509.SubjectName.ToString() + "
"); Response.Write(" Valid From: " + x509.ValidFrom.ToString() + "
"); Response.Write(" Valid Until: " + x509.ValidUntil.ToString() + "
"); Response.Write(" Unique Hash: " + CryptoConvert.ToHex(x509.Hash).ToString() + "
"); // bHowToProceed = true; if (bHowToProceed == true) //Add the certificate to the store. This is Documents and Settingsprogram data.mono. . . if (x509 != null) coll.Add(x509); store.Import(x509); if (bindCount == 1) removeFlag = true; if (bHowToProceed == false) //Remove the certificate added from the store. if (removeFlag == true && bindCount > 1) foreach (X509Certificate xt509 in store.Certificates) if (CryptoConvert.ToHex(xt509.Hash) == CryptoConvert.ToHex(x509.Hash)) store.Remove(x509); Response.Write("SSL Bind Failed."); return bHowToProceed;

Y lo usé en el proceso de encuadernación.

// Create Connection
                LdapConnection conn = new LdapConnection();
                conn.SecureSocketLayer = true;
                Response.Write("Connecting to:" + ldapHost);

                conn.UserDefinedServerCertValidationDelegate += new
                    CertificateValidationCallback(MySSLHandler);

                if (bHowToProceed == false)
                    conn.Disconnect();
                if (bHowToProceed == true)
                
                    conn.Connect(ldapHost, ldapPort);
                    conn.Bind(loginDN, password);
                    Response.Write(" SSL Bind Successfull ");

                    conn.Disconnect();
                
                quit = false;

los key Los elementos están usando el controlador SSL para obtener dinámicamente el certificado, y usando X509StoreManager.LocalMachine para que cuando el sitio web se esté ejecutando, pueda guardar y recuperar los certificados.

91 es “no se puede conectar”. Intente poner el servidor en formato “ldap: // xxxx”, verifique que userDN esté configurado correctamente (con dominio, etc.).

A menudo utilizo WireShark para ver qué está sucediendo a nivel de red (es consciente del protocolo LDAP).

Reseñas y puntuaciones

Eres capaz de añadir valor a nuestra información contribuyendo tu veteranía en las críticas.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *