Foros del Web » Programando para Internet » ASP Clásico »

Active directory

Estas en el tema de Active directory en el foro de ASP Clásico en Foros del Web. Estimados, necesito hacer un login a traves de active directory en un aplicacion ASP. Buscando info por alli encontre el siguiente codigo que llevo varios ...
  #1 (permalink)  
Antiguo 24/11/2008, 13:20
Avatar de Muzztein  
Fecha de Ingreso: agosto-2002
Ubicación: Hangar 18
Mensajes: 1.703
Antigüedad: 22 años, 8 meses
Puntos: 16
Active directory

Estimados, necesito hacer un login a traves de active directory en un aplicacion ASP.

Buscando info por alli encontre el siguiente codigo que llevo varios dias tratando de hacer funcionar sin tener suerte.

Alguno de ustedes ha podido hacer un login utilizando Active Directory?

Algun comentario/tip/sugerencia que pudieran compartir seria de mucha ayuda.
de antemano gracias
Código PHP:

<%

Function 
getADUserInfo(strUID)
    
on error resume next
    strGeneralLookupError 
false
    strBase 
"<LDAP://DC=[DOMAIN], DC=[DOMAIN EXETENTION]>"
    
strFilter "(sAMAccountName=" strUID ")" 
    
strAttributes "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
    'strAttributes = "cn, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
    strScope = "subtree"    
    strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
    set rsADUserInfo = Server.CreateObject("ADODB.Recordset")
    set    rsADUserInfo = connAD.Execute(strFullCommand)
    if err.number <> 0 then
        strGeneralLookupError = true
    end if
    set getADUserInfo = rsADUserInfo
    set rsADUserInfo = Nothing
End Function

Sub getUserData(p_strUserID)
    on error resume next
    set rsUserData = Server.CreateObject("ADODB.Recordset")
    set rsUserData = getADUserInfo(p_strUserID)
    if not rsUserData.EOF then
        strUserGN = rsUserData("givenName")
        strUserSN = rsUserData("sn")
        strUserOU = rsUserData("company")
        strUserEmail = rsUserData("mail")
        strUserPhone = rsUserData("telephoneNumber")
    else
        strADLookupSuccess = false
    end if
    rsUserData.Close
    set rsUserData = Nothing
End Sub

on error resume next

response.expires = 0

DIM connAD, rsUserData, rsADUserInfo
DIM strUserGN, strUserSN, strUserOU, strUserEmail, strUserPhone
DIM strBase, strFilter,strAttributes, strScope, strFullCommand
DIM strGeneralLookupError, strADLookupSuccess
DIM strUserID

strUserGN = "The user can not be found in the system."
strGeneralLookupError = false
strADLookupSuccess = true

set connAD = Server.CreateObject("ADODB.Connection")
connAD.Provider = "ADsDSOObject"
connAD.Properties("User ID") = "[DOMAIN]\[USERNAME]" ' 
### remember to make sure this user has rights to access AD
connAD.Properties("Password") = "[PASSWORD]"
connAD.Properties("Encrypt Password") = true
connAD
.Open

strUserID 
"[USERNAME YOU WANT INFO FOR]"
call getUserData(strUserID)

connAD.Close
set connAD 
Nothing
%>
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<
title>ASP Code to access AD with LDAP Page</title>
</
head>
<
body>
<%=
strUserGN%>&nbsp;
<%=
strUserSN%><br />
<%=
strUserOU%><br />
<%=
strUserEmail%><br />
<%=
strUserPhone%><br />
</
body>
</
html
  #2 (permalink)  
Antiguo 24/11/2008, 14:48
Avatar de JuanRAPerez
Colaborador
 
Fecha de Ingreso: octubre-2003
Mensajes: 2.393
Antigüedad: 21 años, 6 meses
Puntos: 27
Respuesta: Active directory

ummm lee esto:

http://www.forosdelweb.com/f15/adsi-...2003-a-629715/


Código asp:
Ver original
  1. strPath = "LDAP://XXX/DC=XXX,DC=XXX,DC=XX"
  2. strEmail = strCuenta & "@tudominio.xxx.xx"
  3.    
  4. Set objNamespaceLDAP = GetObject("LDAP:")
  5.  
  6. on error resume next
  7.     Set objMyObject = objNamespaceLDAP.OpenDSObject(strPath,strEmail,strClave,0)
  8.  
  9. if err.number <> 0 then
  10.     response.write "<p>Error ingresando en Password Intentelo de nuevo (verifique las condiciones de su teclado)</p>"
  11. else
  12.     response.write "<p>Satisfactorio!!!!!</p>"
  13. end if

comentas
__________________
JuanRa Pérez
San Salvador, El Salvador
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:33.