Richard
Richard

Reputation: 1739

Setting AD "pwdLastSet" to a large value using C#

I'm converting an old VB app to C# and being new to AD, I'm struggling with this bit of code which seems to set the 'pwdLastSet' property to a very high value (so that the user never has to change their password as far as I can tell)

'User must NOT change password at next logon
objLargeInt = CreateObject("LargeInteger")
objLargeInt.LowPart = &HFFFFFFFF
objLargeInt.HighPart = &HFFFFFFFF
Call objUser.Put("pwdLastSet", objLargeInt)

I've tried various methods in C# such as

user.Properties["pwdLastSet"].Value = Int64.MaxValue; 

but nothing I do works (with various error messages). I can't find much in the docs either. I think I might need to use a "LargeInteger" type, and I've added a reference to a COM Library called "Active DS Type Library" but no idea if that's heading in the right direction or how to get any further really.

If someone can give me a clue what to do, I would really appreciate it.

Thanks

Upvotes: 0

Views: 2134

Answers (1)

Alex K.
Alex K.

Reputation: 175866

In vb/s/a &HFFFFFFFF == -1 as there is no unsigned support ... either way using that DS Type reference you can;

 var fatty = new ActiveDs.LargeInteger { HighPart = -1, LowPart = -1 };

Upvotes: 2

Related Questions