Si tu utilise la LDAP en réseaux local, tu n'as pas besoin de login et de mot de passe :
Dim user AsString' Authentification Digest sur iis
user = Request.ServerVariables("REMOTE_USER")Dim RecupUser() AsString
RecupUser = user.Split("\")
user = RecupUser(RecupUser.Length - 1)Dim objPersonne AsNew clsActiveDirectory
Call objPersonne.CherchePersonne(user)
' Fonction dans ma class clsActiveDirectoryPublicSub CherchePersonne(ByVal LeLogin AsString)' Cherche les Informations Sur le Compte suivant le Login TransmisDim searcher AsNew DirectorySearcher(rootEntry)' Mettre ici les valeurs des différents attributssearcher.PropertiesToLoad.Add(
"cn")searcher.PropertiesToLoad.Add(
"givenname")searcher.PropertiesToLoad.Add(
"sn")searcher.PropertiesToLoad.Add(
"telephoneNumber")searcher.PropertiesToLoad.Add(
"mail")searcher.PropertiesToLoad.Add(
"physicalDeliveryOfficeName")searcher.PropertiesToLoad.Add(
"Initials")searcher.PropertiesToLoad.Add(
"Description")searcher.PropertiesToLoad.Add(
"department")searcher.PropertiesToLoad.Add(
"Company")searcher.PropertiesToLoad.Add(
"Title")searcher.PropertiesToLoad.Add(
"employeeType")searcher.PropertiesToLoad.Add(
"employeeNumber")searcher.PropertiesToLoad.Add(
"pager")searcher.PropertiesToLoad.Add(
"carLicense")searcher.PropertiesToLoad.Add(
"homePhone")searcher.PropertiesToLoad.Add(
"otherHomePhone")searcher.PropertiesToLoad.Add(
"homePostalAddress")searcher.PropertiesToLoad.Add(
"roomNumber")searcher.PropertiesToLoad.Add(
"comment")searcher.PropertiesToLoad.Add(
"employeeID")searcher.PropertiesToLoad.Add(
"manager")searcher.PropertiesToLoad.Add(
"proxyAddresses")searcher.Filter =
"(&(anr=" & LeLogin & ")(objectCategory=person))"Dim results As SearchResultCollectionresults = searcher.FindAll()
If results.Count > 0 ThenDim result As SearchResultForEach result In resultsLoginRecherche =
CStr(result.Properties("cn")(0)).ToUpperCheminPersonneRecherche =
CStr(result.Path)TryDim i AsIntegerFor i = 0 To 20ReDimPreserve proxyAddressesRecherche(i)proxyAddressesRecherche(i) = Trim(
CStr(result.Properties("proxyAddresses")(i)))NextCatch ex As ExceptionEndTryTryNomRecherche = Trim(
CStr(result.Properties("sn")(0))).ToUpperCatch ex As ExceptionNomRecherche =
""EndTryTryPrenomRecherche = Trim(
CStr(result.Properties("givenname")(0)))Catch ex As ExceptionPrenomRecherche =
""EndTryTryTelephoneRecherche = Trim(
CStr(result.Properties("telephoneNumber")(0)))Catch ex As ExceptionTelephoneRecherche =
""EndTryTryEmailRecherche = Trim(
CStr(result.Properties("mail")(0)))Catch ex As ExceptionEmailRecherche =
""EndTryTryBureauRecherche = Trim(
CStr(result.Properties("physicalDeliveryOfficeName")(0)))Catch ex As ExceptionBureauRecherche =
""EndTryTryInitialsRecherche = Trim(
CStr(result.Properties("Initials")(0)))Catch ex As ExceptionInitialsRecherche =
""EndTryTryDescriptionRecherche = Trim(
CStr(result.Properties("Description")(0)))Catch ex As ExceptionDescriptionRecherche =
""EndTryTryEntrepriseRecherche = Trim(
CStr(result.Properties("Company")(0)))Catch ex As ExceptionEntrepriseRecherche =
""EndTryTryServiceRecherche = Trim(
CStr(result.Properties("department")(0)))Catch ex As ExceptionServiceRecherche =
""EndTryTryTitreRecherche = Trim(
CStr(result.Properties("Title")(0)))Catch ex As ExceptionTitreRecherche =
""EndTryTryStatutRecherche = Trim(
CStr(result.Properties("employeeType")(0)))Catch ex As ExceptionStatutRecherche =
""EndTryTryNumEmployeRecherche = Trim(
CStr(result.Properties("employeeNumber")(0)))Catch ex As ExceptionNumEmployeRecherche =
""EndTryTryDateNaissanceRecherche = Trim(
CStr(result.Properties("pager")(0)))Catch ex As ExceptionDateNaissanceRecherche =
""EndTryTryParkingRecherche = Trim(
CStr(result.Properties("carLicense")(0)))Catch ex As ExceptionParkingRecherche =
""EndTryTryTelephonePersoRecherche = Trim(
CStr(result.Properties("homePhone")(0)))Catch ex As ExceptionTelephonePersoRecherche =
""EndTryTryPortablePersoRecherche = Trim(
CStr(result.Properties("otherHomePhone")(0)))Catch ex As ExceptionPortablePersoRecherche =
""EndTryTryBadgeRecherche = Trim(
CStr(result.Properties("roomNumber")(0)))Catch ex As ExceptionBadgeRecherche =
""EndTryTryCommentaireRecherche = Trim(
CStr(result.Properties("comment")(0)))Catch ex As ExceptionCommentaireRecherche =
""EndTryTryParcoursProfessionnelRecherche = Trim(
CStr(result.Properties("Description")(0)))Catch ex As ExceptionParcoursProfessionnelRecherche =
""EndTryTryAdressePersoRecherche = Trim(
CStr(result.Properties("homePostalAddress")(0)))Catch ex As ExceptionAdressePersoRecherche =
""EndTryTryIdRecherche = Trim(
CStr(result.Properties("employeeID")(0)))Catch ex As ExceptionIdRecherche =
""EndTryNextEndIfEndSubPour les droits, il suffit ensuite de créer des groupes dans ta LDAP et tu verifies à quel groupe appartient la personne connectée.