Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting the PwdLastSet from ADSI

Reply
Thread Tools

Getting the PwdLastSet from ADSI

 
 
Kenneth Keeley
Guest
Posts: n/a
 
      08-03-2004
Hi,

I am looking for a sample of how to get the password last set for a user in
active directory in a format that we can read. I am using ASP.Net and C# I
have got as far as get the value. but I would like it as a normal date time
value. or at least display it as a string. if I use the code below the
response I get is "The password was last set :System.__ComObject" How do I
get this to a norma date format.

Thanks
Kenneth Keeley

// Create Active Directory Object.
DirectoryEntry AdsiEntry = new DirectoryEntry(_Path, _Domain + @"\" +
_AdminUserName, _AdminPassword);

// Create an Active Directory Search.
DirectorySearcher AdsiSearch = new DirectorySearcher(AdsiEntry);

// Find UserName in Active Directory.
AdsiSearch.Filter = "(SAMAccountName=" + UserName + ")";
SearchResult Result = AdsiSearch.FindOne();

// Get the users directory Entry.
DirectoryEntry UserEntry = Result.GetDirectoryEntry();

// Grab the "pwdLastSet" property.
pwdLastSetVal = UserEntry.Properties["pwdLastSet"].Value;

MyOutPut.Value = "The password was last set :" + pwdLastSetVal + "<br>";


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve logon user name from ADSI venkat ASP .Net 0 11-06-2003 06:41 AM
Access Denied for WMI/ADSI over ASP.Net Roy Osherove ASP .Net 3 09-14-2003 09:47 PM
Getting sub-objects from ADSI Michael P. Nugent Python 0 07-23-2003 06:25 PM
ADSI/LDAP Query khaja shaik ASP .Net 0 07-21-2003 09:05 PM
ADSI - Syntax for msExchTurfListNames Justin Rich ASP .Net 0 06-25-2003 11:19 PM



Advertisments