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
|
string wPath = @"LDAP://" + prmADDomaine + @"/" + prmADOUPath; // Zones de travail pour voir les données en test.
DirectoryEntry dirEntryOU = new DirectoryEntry
(wPath , // Chemin accès O.U. où créer.
prmADAdmin , // Admin de l'O.U. (Chemin d'accès complet).
prmADAdminPwd, // Mot de passe de cet admin.
AuthenticationTypes.ServerBind
);
// --- CRÉATION DU USER sous ce point d'entrée ------------------------------------
DirectoryEntry dirEntryUsr = dirEntryOU.Children.Add("CN=" + this.AD_Matri, "user");
// --- RENSEIGNEMENTS DES CARATÉRISTIQUES DU USER ---------------------------------
dirEntryUsr.Properties["sAMAccountName"].Add(this.AD_Matri);
DirEntryPropCreat(dirEntryUsr, this.AD_NomUser, "sn");
DirEntryPropCreat(dirEntryUsr, this.AD_PrenomUser, "givenName");
DirEntryPropCreat(dirEntryUsr, this.AD_PresentationName, "displayName");
DirEntryPropCreat(dirEntryUsr, this.AD_ServiceUser, "description");
// --- ENVOI DES MODIFICATIONS AU SERVEUR -----------------------------------------
dirEntryUsr.CommitChanges();
// --- NOUVELLES MODIFICATIONS MAIS L'UTILISATEUR DOIT AVOIR ÉTÉ CRÉÉ -------------
dirEntryUsr.Invoke("SetPassword", new object[] { this.AD_MotPasse }); |
Partager