1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| <html>
<BODY>
<form method="post" name="MonForm" action="MAPAGE.asp">
<%
Function UserInCN(LogonUser, Chemin)
' VARIABLES DE CONNEXION A L'ACTIVE DIRECTORY
adUsername=request.form("login")
adPassword=request.form("pass")
set dso = GetObject("LDAP:")
On Error Resume Next
' CONNEXION A L'ACTIVE DIRECTORY
Set obj = dso.OpenDSObject(Chemin, adUsername, adPassword, 1)
If (Err.number <> 0) Then
UserInCN = -1
Exit Function
End If
' POUR CHAQUE MEMBRE TROUVE DANS LE CONTAINER (CN=...)
For Each item In obj.members
' si le membre est un groupe
If (item.Class = "group") Then
' alors on exécute de nouveau la fonction avec le nouveau chemin du container groupe
resultat = UserInCN(LogonUser, item.Adspath)
' lorsque le résultat de la fonction est vrai,
If resultat = 1 Then
UserInCN = 1
session("nomutil") = item.sn
session("prenomutil") = item.givenName
session("auth") = true
if session("nomutil") = "" then
session("nomutil") = LCase(LogonUser)
end if
Exit Function
End If
End If
' si le membre correspond à UserNameLogon alors la fonction retourne 1
If LCase(item.sAMAccountName) = LCase(LogonUser) Then
UserInCN = 1
session("nomutil") = item.sn
session("prenomutil") = item.givenName
session("auth") = true
if session("nomutil") = "" then
session("nomutil") = LCase(LogonUser)
end if
Exit Function
End If
Next
Set obj = Nothing
Set dso = Nothing
UserInCN = 0
End Function
%>
<table border="0" cellspacing="5">
<tr>
<td>Login</td>
<td><input name="login" type="text" id="login2" size="50"></td>
</tr>
<tr>
<td>Mot de passe</div></td>
<td><input name="pass" type="password" id="pass2" size="50"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Connexion"></td>
</tr>
<tr>
<td>
<%
boolIdent = false
if request.form("login")="" and request.form("pass")="" then
response.write("Veuillez saisir votre login et votre mot de passe")
boolIdent = true
else
if request.form("login")="" then
response.write("Veuillez saisir votre login")
boolIdent = true
end if
if request.form("pass")="" then
response.write("Veuillez saisir votre mot de passe")
boolIdent = true
end if
end if
if boolIdent = false then
if UserInCN(request.form("login"),"LDAP://CN=GloEParc,CN=Users,DC="&Application("DC")&",DC="&Application("DC2")&"") <> 1 then
response.write("Le compte n'est pas valide")
end if
end if
%>
</td>
</tr>
</table>
</form>
<%
if boolIdent = false then
session("Authorized") = false
if UserInCN(request.form("login"),"LDAP://CN=Test,CN=Users,DC=dc2,DC=dc2") = 1 then
session("Authorized") = true
response.redirect("index du site.asp")
else
session("Authorized") = false
end if
end if
%>
</body>
</html> |
Partager