Accueil > > > ASP.NET - COMMENT QUESTIONNER UN CONTRÔLEUR DE DOMAINE ACTIVE DIRECTORY
ASP.NET - COMMENT QUESTIONNER UN CONTRÔLEUR DE DOMAINE ACTIVE DIRECTORY
Information sur la source
Description
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
- 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
-
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___)
Historique
- 07 octobre 2004 12:46:43 :
- Ajout de l'import du Namespace de l'AD.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|