471,578 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 software developers and data experts.

How do you uncheck "User cannot change password" and "Password never exipers" attributes in vb.net

Does anyone have any code that can do this. From what I understand,
these 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("userAccountContr ol")

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

Sep 27 '06 #1
0 1579

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by twhan twhan via .NET 247 | last post: by
2 posts views Thread by ChInKPoInt [No MCSD] | last post: by
reply views Thread by damontimm | last post: by
3 posts views Thread by =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.