Directory Services

Setting a User Account Expiration

This code example shows how to set the expiration on a user account.

This operation uses the InvokeMember method to access the IADsUser property AccountExpirationDate.

[C#]
using System.Reflection;
... 
Type type = usr.NativeObject.GetType();
Object adsNative = usr.NativeObject;
type.InvokeMember("AccountExpirationDate", BindingFlags.SetProperty, null, 
adsNative, new object[]{"12/29/2004"});
usr.CommitChanges();