473,586 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the PwdLastSet from ADSI

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.__ComOb ject" 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.
DirectorySearch er AdsiSearch = new DirectorySearch er(AdsiEntry);

// Find UserName in Active Directory.
AdsiSearch.Filt er = "(SAMAccountNam e=" + UserName + ")";
SearchResult Result = AdsiSearch.Find One();

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

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

MyOutPut.Value = "The password was last set :" + pwdLastSetVal + "<br>";
Nov 18 '05 #1
0 3456

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

Similar topics

0
2642
by: Charles LaCour | last post by:
I am looking for a way to list and possibly change the permissions on file shares on Win2K servers via a perl script. I have tried using Win32::OLE to access ADSI objects for the shares but there is no permissions listed. I have looked at Win32NetResource and that has no more info than I can get via ADSI. I have also looked at...
1
1649
by: Ryan Ritten | last post by:
I was wondering if anyone knew how (or if it's even possible) to cache the results of an ADSI call in asp for a longer period of time. Basically what I am doing is I have a website that loads the 'full name' of the user that logs into it. Once the user full nam ehas been retreived (using adsi) the user can reload the page and it appears to...
14
5207
by: Arran Pearce | last post by:
Hi, I am looking for a way to use System.DirectoryServices to find all users on a domain whos accounts are either locked out or disabled. I have used ADSIEdit and the mmc schema add-in to try and find properties for these things but have not had any luck so far. Also i did a search on the Platform SDK doc's. It has examples in VB and C++...
0
1727
by: Dan Nordquist | last post by:
Hey everyone. I'm just getting my feet wet with ADSI (and VB.NET, and ASP.NET, really), but I'm wondering if there's a way to pull a list of distribution lists from an Exchange server using ADSI, LDAP, or anything else in ASP.NET with VB.NET. I'm creating a form that adds new users, and I'd like to be able to ask the user what mail...
3
3628
by: Roy Osherove | last post by:
Hi folks. I have an ASP.Net application that runs a .Net dll that uses WMI and ADSI(both managed) to connect to a given IIS root and search through it. When not using the ASP.Net client, but running from a winforms project - I can connect to both local and remote machines. However, when using the ASP.Net project - I get an "Access denied"...
6
20058
by: Sameh Ahmed | last post by:
Hello there I need to get the "PwdLastSet" of a user object to know when he last set his password. I am using DirectoryServices.DirectoryEntry to bind to the user object, but it either gives "Argument 'Prompt' cannot be converted to type 'String'." or when I use .tostring it returns "system._comobject" I even tried to use this line but it...
3
2229
by: chat_devil | last post by:
hi, does anyone know if it is possible to remove an attribute that can not be read into the ADSI property cache/collection. i'm trying to do an eDirectory password change from .net directory services. eDirectory uses the "userPassword" property to change the password and for a normal user, this has to be deleted and then added to in one...
3
18696
by: martybruce | last post by:
I have some VB.net code. Basically when the user logs into the app. It checks to see if the user's AD account password has expired. If so, It will prompt the user to change it. mydn = GetDN(txtUsername.Text) Dim adsPath As String = "LDAP://" & mydn objUser = New DirectoryEntry(adsPath, txtUsername.Text,
8
3122
by: John | last post by:
Hi, gurus, How can I implement the following feature in C#: Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group") For Each objMember In objGroup.Members WScript.Echo vbCrLf & " Name: " & objMember.Name Next
0
7915
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...
0
7841
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...
0
8204
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. ...
0
8339
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...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5712
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...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.