G
Guest
Using ASP.NET 2.0 I have a webpage to set a users password although it is
taking up to 38 seconds to run. Tracing the code shows that the line of code
used to invoke the new password appears to be the hold up. Any thoughts? Code
is below:
Sub Button_SubmitReset(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit1.Click
Dim AdEntry As New DirectoryEntry("LDAP://" &
AppSettings("DcServerName").ToString() & "/" &
AppSettings("AdPath").ToString(), AppSettings("AdAdminUserName").ToString(),
AppSettings("AdAdminUserPassword").ToString(), AuthenticationTypes.Secure)
Dim AdFilter As String =
"(&(objectCategory=person)(objectClass=user)(UserPrincipalName=" &
Session.Contents("UserPrincipalName") & "*))"
Using AdEntry
Dim AdSearcher As New DirectorySearcher(AdEntry, AdFilter)
Using AdSearcher
AdSearcher.PageSize = 1
AdSearcher.SearchScope = SearchScope.Subtree
Dim Result As SearchResult = AdSearcher.FindOne()
If (Result Is Nothing) Then
lblMessage1.Text = "Unable to retrieve your network account information."
Else
Dim AdUserEntry As DirectoryEntry = Result.GetDirectoryEntry()
' Get auto generated password
Dim strPG As String = ""
strPG = PasswordGenerator()
' Set the password
Trace.Write("Invoke", "--- [ BEGIN ] ---")
AdUserEntry.Invoke("SetPassword", New Object() {strPG})
Trace.Write("Invoke", "--- [ END ] ---")
AdUserEntry.CommitChanges()
' Exit
lblPassword.Text = strPG
strPG = ""
End If
End Using
End Using
End Sub
I appreciate any suggestions.
-brian-
taking up to 38 seconds to run. Tracing the code shows that the line of code
used to invoke the new password appears to be the hold up. Any thoughts? Code
is below:
Sub Button_SubmitReset(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit1.Click
Dim AdEntry As New DirectoryEntry("LDAP://" &
AppSettings("DcServerName").ToString() & "/" &
AppSettings("AdPath").ToString(), AppSettings("AdAdminUserName").ToString(),
AppSettings("AdAdminUserPassword").ToString(), AuthenticationTypes.Secure)
Dim AdFilter As String =
"(&(objectCategory=person)(objectClass=user)(UserPrincipalName=" &
Session.Contents("UserPrincipalName") & "*))"
Using AdEntry
Dim AdSearcher As New DirectorySearcher(AdEntry, AdFilter)
Using AdSearcher
AdSearcher.PageSize = 1
AdSearcher.SearchScope = SearchScope.Subtree
Dim Result As SearchResult = AdSearcher.FindOne()
If (Result Is Nothing) Then
lblMessage1.Text = "Unable to retrieve your network account information."
Else
Dim AdUserEntry As DirectoryEntry = Result.GetDirectoryEntry()
' Get auto generated password
Dim strPG As String = ""
strPG = PasswordGenerator()
' Set the password
Trace.Write("Invoke", "--- [ BEGIN ] ---")
AdUserEntry.Invoke("SetPassword", New Object() {strPG})
Trace.Write("Invoke", "--- [ END ] ---")
AdUserEntry.CommitChanges()
' Exit
lblPassword.Text = strPG
strPG = ""
End If
End Using
End Using
End Sub
I appreciate any suggestions.
-brian-