473,756 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get AD user password expire date?

Trying to get the user password expire date from AD, but there is no such
field.
What I could get is the PasswordLastCha nged property.

Is there anyway I could calculate the date or something?

Regards,
Bryan
Nov 16 '05 #1
5 28317
The pwdLastSet property is a large integer holding the number of 100ns
intervals since 1601 or something - also known as a FILETIME value.

The DateTime class has a "FromFileTime() " method that will convert that into
a date. Watch out for UTC / local time differences.

In order to see when the password will expire you also need to read the
default domain policy to find out how often a user must change a password.

If you use the WinNT ADSI provider instead of the LDAP ADSI provider you
could get the "PasswordExpira tionDate" property which will calculate the
date for you (never tested this though)
Arild

"Bryan Yeo" <br******@comme rce.com.sg> wrote in message
news:O3******** ********@tk2msf tngp13.phx.gbl. ..
Trying to get the user password expire date from AD, but there is no such
field.
What I could get is the PasswordLastCha nged property.

Is there anyway I could calculate the date or something?

Regards,
Bryan

Nov 16 '05 #2
Btw... found this article which may help:
http://msdn.microsoft.com/library/de...ng09102002.asp
Arild

"Arild Bakken" <ar*****@hotmai l.com> wrote in message
news:u7******** ******@TK2MSFTN GP10.phx.gbl...
The pwdLastSet property is a large integer holding the number of 100ns
intervals since 1601 or something - also known as a FILETIME value.

The DateTime class has a "FromFileTime() " method that will convert that into a date. Watch out for UTC / local time differences.

In order to see when the password will expire you also need to read the
default domain policy to find out how often a user must change a password.

If you use the WinNT ADSI provider instead of the LDAP ADSI provider you
could get the "PasswordExpira tionDate" property which will calculate the
date for you (never tested this though)
Arild

"Bryan Yeo" <br******@comme rce.com.sg> wrote in message
news:O3******** ********@tk2msf tngp13.phx.gbl. ..
Trying to get the user password expire date from AD, but there is no such field.
What I could get is the PasswordLastCha nged property.

Is there anyway I could calculate the date or something?

Regards,
Bryan


Nov 16 '05 #3
I have tried the microsoft and try to convert the codes to C#, this is
what I have:

IADsLargeIntege r fds2 =
(IADsLargeInteg er)searchentry2 .Properties["maxPwdAge"].Value;
double ONE_HUNDRED_NAN OSECOND = 10^-7; //.000000100;
int SECONDS_IN_DAY = 86400;
int fgd = (int)fds2.HighP art;
int fgd2 = (int)fds2.LowPa rt;
double dblMaxPwdNano = Math.Abs((int)f ds2.HighPart * 2^32 +
(int)fds2.LowPa rt);
double dblMaxPwdSecs = (int)dblMaxPwdN ano * .000000100;
double dblMaxPwdDays = (int)dblMaxPwdS ecs / SECONDS_IN_DAY;

But there is something either wrong with the code or with the
calculation, I got a zero.
And which policy does the maxpwdage taken from? local security policy,
domain security policy or domain controller policy?

Regards
Bryan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Try this for domain policy enforced pwd. aging.

public static void Main() {
long maxAge;
// Get maxPwdAge from domain
using(Directory Entry domain = new
DirectoryEntry( "LDAP://domain/DC=xxxx,DC=xxxx ,DC=xxx", "xxx\\administr ator",
"ppppp"))
{
LargeInteger liMaxAge =domain.Propert ies["MaxPwdAge"].Value as
LargeInteger;
maxAge = (((long)(liMaxA ge.HighPart) << 32) + (long) liMaxAge.LowPar t);
// SHOULD be a negative value !!!
}
// Get pwdlast set for user (here administrator)
DirectoryEntry user = new
DirectoryEntry( "LDAP://domain/CN=administrato r,cn=users,DC=c eleb,DC=w2kdom, DC=com",
"xxx\\administr ator", "xxxxx");
LargeInteger li = user.Properties["pwdLastSet "].Value as LargeInteger;
long expDate = (((long)(li.Hig hPart) << 32) + (long) li.LowPart) - maxAge;
// !!! maxAge is negative number!!!
LiToDate(expDat e);
}
}
static void LiToDate(long date)
{
Console.WriteLi ne(date);
string dt = DateTime.FromFi leTime(date).To String(); // To file time
Console.WriteLi ne("DATE = {0:D}" ,dt); // show pwd expiry date
}
....

Willy.

"Bryan Yeo" <br******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I have tried the microsoft and try to convert the codes to C#, this is
what I have:

IADsLargeIntege r fds2 =
(IADsLargeInteg er)searchentry2 .Properties["maxPwdAge"].Value;
double ONE_HUNDRED_NAN OSECOND = 10^-7; //.000000100;
int SECONDS_IN_DAY = 86400;
int fgd = (int)fds2.HighP art;
int fgd2 = (int)fds2.LowPa rt;
double dblMaxPwdNano = Math.Abs((int)f ds2.HighPart * 2^32 +
(int)fds2.LowPa rt);
double dblMaxPwdSecs = (int)dblMaxPwdN ano * .000000100;
double dblMaxPwdDays = (int)dblMaxPwdS ecs / SECONDS_IN_DAY;

But there is something either wrong with the code or with the
calculation, I got a zero.
And which policy does the maxpwdage taken from? local security policy,
domain security policy or domain controller policy?

Regards
Bryan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #5
Thanks for the code, it's a great help.
Trying to figure out for days already.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
11025
by: Geoff Muldoon | last post by:
Hi all, Help please. Environment: Unix (Tru64) / Apache / PHP4.0.6 / Oracle8i Establish connection to Oracle: for ($I=0; $I<$max_attempts; $I++) {
15
7663
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not there at all? Any feedback would be helpful. Thanks! -Josh
0
2767
by: Bob Rivers | last post by:
Hi, I have an application that uses jdbc (9.2.0.3/classes12) to connect to an Oracle db (9i). It works fine, except when the user password is going to expire. Let me try to explain (sorry my poor english): my oracle db manages the users passwords, and this passwords are configured to expire every 90 days. So, when the password are going to expire, oracle asks to users if they want to change it.
7
7211
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local time reaches the set expire-time. But if it is an expire time set on my server in California, and the cookie is put on a computer that is running on London Time, and the expire time is set at the server as 20 minutes from now, the London computer...
0
1499
by: Kenneth Keeley | last post by:
Hi, How can I do the below code in ASP.Net as I wish to provide an indication to my staff on our Intranet site of when they will need to change there password. On Error Resume Next Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D Const ONE_HUNDRED_NANOSECOND = .000000100
2
9001
by: Fabrice | last post by:
Hello, I 'would like to build a system (based on database, not SqlServer but MySQL) to permit only one session per user. I'm using a form athentication. My Solution : --------------- When a connection is established by a user, I realize an insert in a Table, named tbLogin with many informations such as idUser, SessionId, Guid, Date,
23
3213
by: Phil Powell | last post by:
// OBTAINED FROM http://www.javascripter.net/faq/settinga.htm // NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY AND THUS EXPIRE function setCookie(name, value, days, docObj) { var today = new Date(); var expire = new Date(); if (days == null || isNaN(days) || days == 0) days = 1; if (days >= 1 || days < 0) expire.setTime(today.getTime() + 3600000 * 24 * days);
32
5023
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is not a function" ---------------------------------------------------- I have this in a .js file and in the head section.
3
2400
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains Home, Retail Contact Us
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.