Set XP Account Password to Never Expire

Discussion in 'Scripting' started by Dan, Aug 8, 2003.

  1. Dan

    Dan Guest

    I need to be able to create a local account, make it a
    member of the Administrators group, and make it so the
    password never expires.

    I have been able to accomplish the first two tasks but I
    need to know the property and value to make it so the
    password never expires.

    Thanks,
    Dan
     
    Dan, Aug 8, 2003
    #1
    1. Advertisements

  2. The documentation for the properrty you're looking for is at:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/iadsuser.asp

    Here are the user flags:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/ads_user_flag_enum.asp


    I'm intentionally giving you more info so that you know where to look.

    --
    //David
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //
    I need to be able to create a local account, make it a
    member of the Administrators group, and make it so the
    password never expires.

    I have been able to accomplish the first two tasks but I
    need to know the property and value to make it so the
    password never expires.

    Thanks,
    Dan
     
    David Wang [Msft], Aug 9, 2003
    #2
    1. Advertisements

  3. One tiny comment:

    Realize that the XOR is toggling that bit -- though the default setting is
    disabled, so it should toggle "Don't Expire Password" to be enabled, as you
    desired.

    Use OR if you intend to switch the bit to be always enabled.

    --
    //David
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //
    Hi,

    In other words, you need to use the WinNT provider and set the userFlags
    attribute using the ADS_UF_DONT_EXPIRE_PASSWD bit mask (after the user
    object is created):

    Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
    lngFlags = objUser.Get("userFlags")
    lngFlags = lngFlags Xor ADS_UF_DONT_EXPIRE_PASSWD
    objUser.Put "userFlags", lngFlags
    objUser.SetInfo
     
    David Wang [Msft], Aug 11, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.