我正在使用基於Web的「忘記密碼」重置AD密碼。好吧,我可以解鎖用戶,但不能更改密碼。在.NET中忘記Active Directory密碼腳本
這裏是我的功能:
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
A面的問題 - 任何人都建議我,我怎樣才能解決硬編碼的管理員用戶頁?將創建一個具有幾個管理員權限的IUSR工作?
任何幫助表示讚賞!
當您嘗試設置密碼時,您是否遇到異常? – guanome 2011-04-26 14:05:46
我沒有得到異常。 – NeerPatel 2011-04-26 15:02:36
那麼,它只是默默地失敗了? – guanome 2011-04-26 18:41:40