views:

582

answers:

1

Hello i try to put the user password check to never expire. When i create the user, the check is always uncheck. I try many twist to execute that but noting work.

There is my code.

DirectoryEntry user = root.Children.Add(adUserName, "user");
          // NOTE(cboivin): Documentation : http://msdn.microsoft.com/en-us/library/aa746340(VS.85).aspx         
          user.Invoke("SetPassword", new object[] { adUserPassword });
          // NOTE(cboivin): Ne pas mettre les clefs dans les ressources, Description, PasswordExpirationDate, AccountExpirationDate
          user.Invoke("Put", new object[] { "Description", Nms.SiteAccess.Business.Manager.ActiveDirectory._resources.WindowsPermissionManager.UserCreerAutomatiquement + args.AddDescriptif });
          user.Invoke("Put", new object[] { "PasswordExpirationDate", args.PasswordExpiration });
          user.Invoke("Put", new object[] { "AccountExpirationDate", args.AccountExpiration });

          user.CommitChanges();

Anny idéa ?

+2  A: 

Check out this SO thread ...

user.Invoke("Put", new object[] {"UserFlags", 0x10000});
JP Alioto
Excellent !!!! Thanks very much
Cédric Boivin