[英]Forgot Active Directory Password Script in .NET
我正在使用LDAP在基於Web的“忘記密碼”上重置AD密碼。 好吧,我可以解鎖用戶,但不能更改密碼。
這是我的功能:
Private Function ChangeLocalUserPassword(ByVal User As String, ByVal Pass As String) As Boolean
Dim pinger As New Net.NetworkInformation.Ping
Dim usr As DirectoryEntry
_de = GetDirectoryEntry()
If _de Is Nothing Then
'couldn't connect or find account
MsgBox("_de is Nothing")
Return False
End If
Try
usr = _de.Children.Find("CN=" & User, "User")
Catch ex As Exception
MsgBox("User could not be found!")
Return False
End Try
Try
usr.Invoke("SetPassword", Pass)
usr.CommitChanges()
usr.Properties("LockOutTime").Value = 0
usr.CommitChanges()
Catch ex As Exception
MsgBox("Error is " & ex.Message)
Return False
End Try
End Function
這是我的GetDirectoryEntry函數:
Private Function GetDirectoryEntry() As DirectoryEntry
Dim dirEntry As DirectoryEntry = New DirectoryEntry()
dirEntry.Path = "LDAP://<SERVER>/ou=<OU>,dc=<DOMAIN>"
dirEntry.Username = "<DOMAIN>\Administrator"
dirEntry.Password = "<PASSWORD>"
Return dirEntry
End Function
附帶問題-有人向我建議,如何解決對頁面上的Admin用戶進行硬編碼的問題? 創建具有幾個Admin特權的IUSR是否可行?
任何幫助表示贊賞!
要重置密碼,PwdLastSet是鍵屬性。 如果PwdLastSet的值設置為零,則用戶在登錄時必須更改其密碼( 請參閱文章 )。
對於您的另一個問題:
在Active Directory中創建一個新用戶。
在目標組織單位中,或直接在域容器中,您只需要向新用戶委派重設密碼的權利。 因此,您的應用程序只操作允許重設密碼的用戶和密碼。
在AD中創建組,創建用戶,將密碼更改選項委派給該組,通常在OU級別完成。 這是大多數組織具有幫助台功能時的方式。
http://www.windowsecurity.com/articles/Implementing-Active-Directory-Delegation-Administration.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.