|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do you uncheck "User cannot change password" and "Password never exipers" attributes in vb.netthese are flags in the "userAccountControl" properties but unsure how to get it unchecked. Can anyone help? Imports System Imports System.DirectoryServices Namespace ActiveDirectorySearch Public Class ADSearch Shared Sub main(ByVal strUserName As String) Dim Entry As New DirectoryEntry("LDAP://server/dc=fully,dc=qualified,dc=domain") Dim DSESearcher As New DirectorySearcher(Entry) Dim strFilter As String = "(sAMAccountName=" & strUserName & ")" Dim objUser As DirectoryEntry DSESearcher.SearchScope = SearchScope.Subtree DSESearcher.Filter = strFilter DSESearcher.PropertiesToLoad.Add("pwdLastSet") DSESearcher.PropertiesToLoad.Add("userAccountControl") Dim objResult As SearchResult = DSESearcher.FindOne If Not objResult Is Nothing Then objUser = objResult.GetDirectoryEntry objUser.Properties("pwdLastSet").Value = 0 objUser.CommitChanges() End If End Sub End Class End Namespace |
|||||||||||||||||||||||