G
Guest
I'm changing passwords every so often with my VB.net app using the NetUserSetInfo API call.
I found that it is very slow, on a 3 GHz P4 it uses 18 seconds to change 100 passwords. Anyone
else have the same experience ? I know for a fact that the code works. My VB.net code is as
follows:
Public Sub ChangePasswords()
msgbox(now)
Dim i As Integer
For i = 0 To 100
Try
Dim retVal As Long
Dim servername As String = "WINXPPRO"
Dim username As String = "testuser1"
Dim password As String = "testpassword" & i
retVal = NetUserSetInfo(servername, username, 1003, password, 0)
If retVal <> 0 Then
If retVal = 2221 Then
Err.Raise(retVal, Nothing, "Unknown user '" & username & "'")
Else
Err.Raise(retVal, Nothing, "NetUserSetInfo() failed with code " & retVal)
End If
End If
Catch
EventLog.WriteEntry(Err.Source, Err.Description)
End Try
Next i
msgbox(now)
End Sub
' API function declared
Declare Unicode Function NetUserSetInfo Lib "netapi32.dll" ( _
ByVal servername As String, ByVal username As String, _
ByVal level As Integer, ByRef buf As String, _
ByRef parm_err As Integer) As Integer
I found that it is very slow, on a 3 GHz P4 it uses 18 seconds to change 100 passwords. Anyone
else have the same experience ? I know for a fact that the code works. My VB.net code is as
follows:
Public Sub ChangePasswords()
msgbox(now)
Dim i As Integer
For i = 0 To 100
Try
Dim retVal As Long
Dim servername As String = "WINXPPRO"
Dim username As String = "testuser1"
Dim password As String = "testpassword" & i
retVal = NetUserSetInfo(servername, username, 1003, password, 0)
If retVal <> 0 Then
If retVal = 2221 Then
Err.Raise(retVal, Nothing, "Unknown user '" & username & "'")
Else
Err.Raise(retVal, Nothing, "NetUserSetInfo() failed with code " & retVal)
End If
End If
Catch
EventLog.WriteEntry(Err.Source, Err.Description)
End Try
Next i
msgbox(now)
End Sub
' API function declared
Declare Unicode Function NetUserSetInfo Lib "netapi32.dll" ( _
ByVal servername As String, ByVal username As String, _
ByVal level As Integer, ByRef buf As String, _
ByRef parm_err As Integer) As Integer