G
Guest
Hi,
After inserting 2500 users, i would like to set their password and enable
them (noexpire). I'm getting no error errors when i run the procedure, and
i've seen this technique before on internet. But it doesn't work... Anybody
have any ideas??
Thanks in advance!
Rob Smeets
I'm using the following code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Try
Dim x As Integer
For x = 0 To Users1.Userlist.Rows.Count - 1
If Users1.Userlist.Rows(x).Item("Selected") = True Then
Dim objUser As
New DirectoryServices.DirectorySearcher(TextBox2.Text)
Dim child As System.DirectoryServices.DirectoryEntry
objUser.Filter = "sAMAccountName=" +
Users1.Userlist.Rows(x).Item
("UserName")
Dim objSearchResult As DirectoryServices.SearchResult
For Each objSearchResult In objUser.FindAll()
objSearchResult.GetDirectoryEntry().Properties.
("UserAccountControl").Value = 66048
Users1.Userlist.Rows(x).Item("Enabled") = "66048"
objSearchResult.GetDirectoryEntry().CommitChanges()
Next
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
After inserting 2500 users, i would like to set their password and enable
them (noexpire). I'm getting no error errors when i run the procedure, and
i've seen this technique before on internet. But it doesn't work... Anybody
have any ideas??
Thanks in advance!
Rob Smeets
I'm using the following code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Try
Dim x As Integer
For x = 0 To Users1.Userlist.Rows.Count - 1
If Users1.Userlist.Rows(x).Item("Selected") = True Then
Dim objUser As
New DirectoryServices.DirectorySearcher(TextBox2.Text)
Dim child As System.DirectoryServices.DirectoryEntry
objUser.Filter = "sAMAccountName=" +
Users1.Userlist.Rows(x).Item
("UserName")
Dim objSearchResult As DirectoryServices.SearchResult
For Each objSearchResult In objUser.FindAll()
objSearchResult.GetDirectoryEntry().Properties.
("UserAccountControl").Value = 66048
Users1.Userlist.Rows(x).Item("Enabled") = "66048"
objSearchResult.GetDirectoryEntry().CommitChanges()
Next
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub