Salut à tous!
Je voudrais SVP,un exemple de code c# qui montre le bouton(par exemple bouton Enregistrer) inactif d'un form suivant le Profil(Admin,User) une fois connecté
Merci!
Salut à tous!
Je voudrais SVP,un exemple de code c# qui montre le bouton(par exemple bouton Enregistrer) inactif d'un form suivant le Profil(Admin,User) une fois connecté
Merci!
Ashfor76,
Une solution sans rentrer dans les détails de l'UAC (form load):
Salutations.
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 using System.Security.Principal; void Form1_Load(object sender, EventArgs e) { try { // si admin > enabled btEnreg.Enabled = new WindowsPrincipal(WindowsIdentity.GetCurrent()) .IsInRole(WindowsBuiltInRole.Administrator); } catch (Exception) { throw new InvalidOperationException("Couldn't get the current user identity"); } }
Partager