how to get Password expiration date in worklfow for a AD user.
I am trying to get AD user password expiration Days in worklfow is there a way to do this, i tried the Script but the script i am using needs to import a reference library and i am not able to do that.
is there any other waty to retrive it.
script i used
it uses ActiveDs got Largeinteger.
DirectoryEntry entry = new DirectoryEntry("LDAP://whqs45/DC=***,DC=***");
string filter = "(&(objectClass=user)(objectCategory=person)(sAMAccountName="+userID+"))";
DirectorySearcher search = new DirectorySearcher(entry, filter);
search.SearchScope = SearchScope.Subtree;
SearchResult result = search.FindOne();
entry = result.GetDirectoryEntry();
// Pulling the informtion on when the password was last changed and converting it to a LargeInteger.
LargeInteger liAcctPwdChange = entry.Properties["pwdLastSet"].Value as LargeInteger;
// Convert the highorder/loworder parts of the property pulled to a long.
long dateAcctPwdChange = (((long)(liAcctPwdChange.HighPart) << 32) + (long)liAcctPwdChange.LowPart);
// Convert FileTime to DateTime and get what today's date is.
DateTime dtNow = DateTime.Now;
// I added 90 days because I know what my password expiration is set to, if not you need to pull that information and add the number of days it is set for.
DateTime dtAcctPwdChange = DateTime.FromFileTime(dateAcctPwdChange).AddDays(90);
string strAcctPwdChange = DateTime.FromFileTime(dateAcctPwdChange).ToShortDateString();
string strAcctPwdExpires = DateTime.FromFileTime(dateAcctPwdChange).AddDays(90).ToShortDateString();
// Calculate the difference between the date the pasword was changed, and what day it is now and display the # of days.
time = dtAcctPwdChange - dtNow;
string changedp= strAcctPwdChange;
string expirep = strAcctPwdExpires;
string daysp = time.Days.ToString() + " day(s)";