Change the "User must change password at next logon" attribute


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Change the "User must change password at next logon" attribute

  1. #1
    Join Date
    Sep 2006
    Posts
    8

    Red face Change the "User must change password at next logon" attribute

    im working on a app that will got through a pre defined list and people and set the "Change password at next logon" to 1 but not sure how to do this. I have gotten to the point where im finding the user by GetDirectoryEntry.Username but unsure how to find and set this attribute. Any help would be appreciated. here is the code so far


    Imports System
    Imports System.DirectoryServices

    Namespace ActiveDirectorySearch
    Public Class ADSearch
    Shared Sub main(ByVal strUserName As String)

    Dim DSESearcher As New DirectoryServices.DirectorySearcher
    Dim RootDSE As String = DSESearcher.SearchRoot.Path

    RootDSE = RootDSE.Insert(7, "ou=MINN Corporate,ou=Corp Users,")

    Dim MySearcher As DirectorySearcher = New DirectorySearcher(RootDSE)
    Dim objResults As SearchResult

    MySearcher.Filter = "(ObjectType=User)"

    For Each objResults In MySearcher.FindAll()

    If objResults.GetDirectoryEntry.Username.ToString = strUserName Then


    End If
    Next
    End Sub
    End Class
    End Namespace
    Last edited by Code_Ninja; 09-22-2006 at 06:59 PM.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    You need to reset the pwdLastSet property to 0.

    http://msdn2.microsoft.com/en-us/library/ms180915.aspx
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Sep 2006
    Posts
    8
    Im sorry but do you think you could show me in code. Im good at picking this up when I can see it. Also I noticed a reference to ActiveDS namespace. I dont seem to see that in the list of available refrences.

  4. #4
    Join Date
    Dec 2003
    Posts
    2,750
    I'll see if I can come up with an example. This is a property for the User object, which should be the result of your search.

    The reference to ActiveDS is the COM interop library for ADSI. You don't need it for expiring the password.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Similar Threads

  1. Unable to change AD password
    By kneese in forum VB Classic
    Replies: 0
    Last Post: 11-08-2005, 07:56 PM
  2. HPUX - Change password from Informix stored procedure
    By Dan Thibodeaux in forum Database
    Replies: 0
    Last Post: 04-14-2003, 01:54 PM
  3. Change Password
    By rkbnair in forum Database
    Replies: 1
    Last Post: 03-12-2002, 10:22 AM
  4. stored procedure to change password
    By sheryl kemp in forum Database
    Replies: 1
    Last Post: 02-14-2002, 11:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center