Advertisement
Guest User

Untitled

a guest
Dec 16th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. protected void btnLogin_Click(object sender, EventArgs e)
  2. {
  3.  
  4.  
  5. string Server = "10.0.103.19:389";
  6. string ruta = "LDAP://" + Server + "/CN=Users,DC=finuniversal,DC=Local";
  7. DirectoryEntry raiz = new DirectoryEntry(ruta);
  8. raiz.Path = ruta;
  9. raiz.AuthenticationType = AuthenticationTypes.Secure;
  10. raiz.Username = txtUsuario.Text;
  11. raiz.Password = txtContrasena.Text;
  12.  
  13. string filtro = "sAMAccountName";
  14. string strSearch = filtro + "=" + txtUsuario.Text;
  15. DirectorySearcher dsSystem = new DirectorySearcher(raiz, strSearch);
  16. dsSystem.SearchScope = SearchScope.Subtree;
  17. try
  18. {
  19. Session["usuario"] = txtUsuario.Text;
  20. SearchResult srSystem = dsSystem.FindOne();
  21. Response.Redirect(Page.ResolveClientUrl("Panel.aspx"));
  22.  
  23. }
  24. catch (Exception error)
  25. {
  26. ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Verifique los Datos Correctos')", true);
  27. /* Response.Write(error.Message); */
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement