none
Ayuda Error active directory +"a referral was returned from the server"

    Pregunta

  • Me podrian ayudar con este error tratando de accesar el directorio activo desde C#.

    "a referral was returned from the server"

    Mil Gracias.

    // Create the context for the principal object. 
                    PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
                                                                txtDominio.Text,
                                                                "DC=" + txtDominio.Text + ",DC=com");
    
                    // Create an in-memory user object to use as the query example.
                    UserPrincipal u = new UserPrincipal(ctx);
    
                    // Set properties on the user principal object.
                    //u.GivenName = txtUsuario.Text;
                    u.SamAccountName = txtUsuario.Text;
                    //u.Surname = "";           
                                    
    
                    // Create a PrincipalSearcher object to perform the search.
                    PrincipalSearcher ps = new PrincipalSearcher();
    
                    // Tell the PrincipalSearcher what to search for.
                    ps.QueryFilter = u;
    
                    // Run the query. The query locates users 
                    // that match the supplied user principal object. 
                    PrincipalSearchResult<Principal> results = ps.FindAll();
    
                    foreach (Principal cr in results)
                    {
                        //Debug.Print(cr.Name)
                        //USUARIO VALIDO
                        listBox1.Items.Add(cr.Name);
                        listBox1.Items.Add(cr.SamAccountName);
                        Existe = "Si";
                    }
                    if (Existe == "No")
                    {
                        listBox1.Items.Add("Usuario no encontrado!");
                    }
    
    


     

    sábado, 21 de enero de 2012 1:23

Respuestas

Todas las respuestas