[2.0][active directory] problème d'intéraction avec Active directory
Bonjour à tous ,
Voila j'essaye de créer des user dans un active directory mais voila quand j arrive au commichanges il plante et me donne une exception
voilà le code
Code:
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
| DirectoryEntry Ldap = new DirectoryEntry("LDAP://OU=Users,OU=External,DC=za-insurances,DC=local");
DirectoryEntry user = Ldap.Children.Add("cn=" + givenName + " " + sn, "user");
user.Properties["SAMAccountName"].Add(SAMAccountName.ToString());
user.Properties["sn"].Add(sn.ToString());
user.Properties["givenName"].Add(givenName.ToString());
//ajout marc
user.Properties["Regional-Settings"].Add(mail.ToString());
user.Properties["EntityID"].Add(telephoneNumber.ToString());
user.Properties["Default-UI-language"].Add(mail.ToString());
user.Properties["Default-DA-language"].Add(telephoneNumber.ToString());
user.Properties["Default-DA-mail"].Add(mail.ToString());
user.Properties["Default-DA-printer"].Add(telephoneNumber.ToString());
user.Properties["state"].Add(state.ToString());
user.Properties["profil"].Add(profil.ToString());
user.Properties["group"].Add(group.ToString());
//fin ajout
user.CommitChanges();
user.Invoke("SetPassword", new object[] { password });
user.Properties["userAccountControl"].Value = 0x0200;
user.CommitChanges();
return true; |
et l'exception
Citation:
A first chance exception of type 'System.DirectoryServices.DirectoryServicesCOMException' occurred in System.DirectoryServices.dll
The program '[3228] WebDev.WebServer.EXE: Managed' has exited with code 0 (0x0).
Merci d'avance