Bonjour,

Je suis débutant en csharp.
J'espère arriver à me faire comprendre.

J'ai créé la class suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
public class MembreAD
    {
        public string distinguishedname = null;
        public string countrycode = null;
        public string cn = null;
        public string lastlogoff = null;
        public string adspath = null;
        public string ipphone = null;
        public string facsimiletelephonenumber = null;
        public string usncreated = null;
        public string objectguid = null;
        public string othermobile = null;
        public string whenchanged = null;
        public string memberof = null;
        public string homephone = null;
        public string accountexpires = null;
        public string displayname = null;
        public string profilepath = null;
        public string primarygroupid = null;
        public string badpwdcount = null;
        public string objectclass = null;
        public string objectcategory = null;
        public string instancetype = null;
        public string homedrive = null;
        public string info = null;
        public string samaccounttype = null;
        public string homedirectory = null;
        public string whencreated = null;
        public string lastlogon = null;
        public string useraccountcontrol = null;
        public string otheripphone = null;
        public string samaccountname = null;
        public string employeetype = null;
        public string givenname = null;
        public string mail = null;
        public string objectsid = null;
        public string lockouttime = null;
        public string mobile = null;
        public string description = null;
        public string scriptpath = null;
        public string pwdlastset = null;
        public string wwwhomepage = null;
        public string logoncount = null;
        public string codepage = null;
        public string name = null;
        public string usnchanged = null;
        public string pager = null;
        public string userprincipalname = null;
        public string badpasswordtime = null;
        public string employeeid = null;
        public string sn = null;
        public string telephonenumber = null;
        public string logonhours = null;
    }
Elle utilise les différentes prorperties d'un utilisateur de l'actice directory.

J'ai fais une routine qui me permet de récupérer ces infos

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
            MembreAD Membre = new MembreAD();
 
            DirectoryEntry Objet = new DirectoryEntry("LDAP://" + Utilisateur);
            DirectorySearcher Recherche = new DirectorySearcher(Objet);
            SearchResult Resultat = Recherche.FindOne();
            DirectoryEntry Valeurs = Resultat.GetDirectoryEntry();
 
            ResultPropertyCollection ResultatCollection;
            ResultatCollection = Resultat.Properties;
 
            foreach (string Cle in ResultatCollection.PropertyNames)
            {
 
                foreach (Object Collection in ResultatCollection[Cle])
                {
                    string Contenu = Collection.ToString();
                }
            }
Ce que je voudrais c'est remplir automatiquement ma variable "membre" qui est de type "MembreAD" par les valeurs obtenues successivement dans "Contenu.

Je ne sais pas le faire.

Merci de mmontrer comment.