Change expired password in AD with C# (使用c# 更改AD 中過期密碼)

Question:

 

Hello,

I'm looking for a solution to completely replace iisadmpwd with a pure ASP.NET 2.0 solution.

We are using windows authentication with a web application.
If the user's password is expired we need to enable him to change his old password via a web
interface. That can be a complete web application of it's own.

Iisadmpwd seems very outdated and the persons in charge of that particular project won't
accept this 'old-fashioned asp and vb thing' to do the job.

I found a solution to change a local computer account password here: http://forums.asp.net/t/379197.aspx
But this does not work if the account in question has a expired password. So that's not
a thing that is going to help.

I searched half a day here in the forums, on google, on codeplex, but I did not find a suitable solution.

Do you know a solution for this, that will work on local computer accounts as well as on domain accounts?

Regards, 

   Sebastian

 

Solution:

Hi,

Have you read this one?

 http://directoryprogramming.net/forums/thread/5289.aspx

try this code:

DirectoryEntry dirEntry = (DirectoryEntry)usr.GetUnderlyingObject();
dirEntry.Properties["pwdLastSet"].Value = 0;
dirEntry.CommitChanges();


dirEntry.Properties["pwdLastSet"].Value = -1;
dirEntry.CommitChanges();

 

 use this code to refresh expired password. then, change the password.

Hope it helps

Regards

 

Relative links:

http://forums.asp.net/p/1368570/2861644.aspx#2861644

http://forums.asp.net/t/379197.aspx

http://directoryprogramming.net/forums/thread/5289.aspx

 

 

發佈了70 篇原創文章 · 獲贊 1 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章