Dans le cadre de l'administration des Utilisateurs sur un domaine Active Directory, un système d'intérogation du Contrôleur de Domaine est bien utile pour récupérer toutes les informations disponible sur un Utilisateur.
Par exemple :
Connaître le Nom et Prénom de la personne se connectant avec le login toto10
Source / Exemple :
Imports System.DirectoryServices
...
' Le code de la fonction simple
' -----------------------------------------------------
Public ChaineConn As String = "LDAP://MonControleurdeDomaineActiveDirectory"
Public rootEntry As New DirectoryEntry(ChaineConn, LoginAD, PasswordAD)
Public Login As String = ""
Public Nom As String = ""
Public Prenom As String = ""
Public Telephone As String = ""
Public Email As String = ""
Public Bureau As String = ""
Public Initials As String = ""
Public Description As String = ""
Public Entreprise As String = ""
Public Service As String = ""
' -----------------------------------------------------
Public Sub CherchePersonne(ByVal LeLogin As String)
' Cherche les Informations Sur le Compte suivant le Login Transmis
Dim searcher As New DirectorySearcher(rootEntry)
' Mettre ici les valeurs des différents attributs
searcher.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.Filter = "(&(anr=" & LeLogin & ")(objectCategory=person))"
Dim results As SearchResultCollection
results = searcher.FindAll()
If results.Count > 0 Then
Dim result As SearchResult
For Each result In results
Login = CStr(result.Properties("cn")(0))
If Not (result.Properties("givenname") Is Nothing) Then
Nom = Trim(CStr(result.Properties("givenname")(0)))
End If
If Not (result.Properties("sn") Is Nothing) Then
Prenom = Trim(CStr(result.Properties("sn")(0)))
End If
If Not (result.Properties("telephoneNumber") Is Nothing) Then
Telephone = Trim(CStr(result.Properties("telephoneNumber")(0)))
End If
If Not (result.Properties("mail") Is Nothing) Then
Email = Trim(CStr(result.Properties("mail")(0)))
End If
If Not (result.Properties("physicalDeliveryOfficeName") Is Nothing) Then
Bureau = Trim(CStr(result.Properties("physicalDeliveryOfficeName")(0)))
End If
If Not (result.Properties("Initials") Is Nothing) Then
Initials = Trim(CStr(result.Properties("Initials")(0)))
End If
If Not (result.Properties("Description") Is Nothing) Then
Description = Trim(CStr(result.Properties("Description")(0)))
End If
If Not (result.Properties("Company") Is Nothing) Then
Entreprise = Trim(CStr(result.Properties("Company")(0)))
End If
If Not (result.Properties("department") Is Nothing) Then
Service = Trim(CStr(result.Properties("department")(0)))
End If
Next
End If
End Sub
Conclusion :
On peut très bien a partir de ce système faire une personnalisation d'une page Intranet avec Authentification sur le Contrôleur LDAP.
Ainsi une fois que toto10 aura entré son mot de passe pour lancer la page Intranet de son entreprise il verrait apparaître son nom prénom, ...
De la même facon un Annuaire complêt d'une entreprise avec un AD déja enrichi peut être "Webisé".
Romelard Fabrice (Alias F___)
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.