Question

Active Directory Properties for "User Cannot Change Password"

Asked by: frodoman

We're running active directory on a Win2000 server.  I am trying with a .net application to produce a list of all users that have the property "user cannot change password" enabled.

From what I've read I thought I would be able to obtain this by examing the userAccountControl property for the PASSWD_CANT_CHANGE value of 64.  My actual results however are showing a value of 66048 which I interpret to mean DONT_EXPIRE_PASSWORD (65536) + NORMAL_ACCOUNT (512).  I am getting the value of 66048 for users whether or not they have their user cannot change password flag enabled.

I am far from being an expert working with AD so any explanations or suggestions would be appreciated.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-08-29 at 05:56:47ID22794119
Tags

change

,

password

,

cannot

,

directory

,

active

Topics

Windows 2000 Server

,

Active Directory

Participating Experts
2
Points
500
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. passwd
    i want to enforce the passwd command to force my users to not use passwds that are based on dictionary words, but all that it does is just warn them, how can i enforce this?
  2. passwd
    I have been working with tcl and expect trying to get an html page to change a users name and password for them. Either I did something or the expect program did something. Now when I log on to the Unix box and type passwd I get the following response: passwd: Changing pas...
  3. Password Expiration notices wrong
    Server 2003 network, XP SP2 Clients. Occasionally some of my users are getting password expiration notices that are totally wrong, like for 90 days or 200 days etc. They should just be getting them 14 days before the expiration. Any help for this?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: opie6373Posted on 2007-08-29 at 06:19:37ID: 19790871

i found this script that you might try... it involves a command line tool dsquery

http://www.jsifaq.com/SF/Tips/Tip.aspx?id=7687

 

by: opie6373Posted on 2007-08-29 at 06:24:38ID: 19790919

 

by: frodomanPosted on 2007-08-29 at 07:05:17ID: 19791358

I appreciate your response but unfortunately that doesn't help me.  I can get the values out fine they just aren't the results I'm expecting.

For a simple test case and cleared all of the optional properties for a user and query the userAccountControl value and get a result of 512 (Normal Account).  Now I edit the user and check "User Cannot Change Passoword" and run my query again and I still get a result of 512 - as I understand it I should get a result of 576 (512 + 64).  [ I also tried a custom search within AD using: (&(objectclass=person) (userAccountControl=576)) and it didn't return any values so I don't think the problem is with retrieving the values. ]

I suspect there is something basic I'm missing or something with the way our AD is setup that is obscuring this value.

Any other thoughts?

 

by: opie6373Posted on 2007-08-29 at 07:26:20ID: 19791579

i don't know but i found a freeware tool that you might be able to use with better results

http://joeware.net/freetools/tools/adfind/index.htm

i found it in this thread

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_2003_Active_Directory/Q_22787115.html

 

by: frodomanPosted on 2007-08-29 at 07:37:51ID: 19791696

Again appreciate the suggestion but no luck.  adfind search returns the same results.

 

by: Chris-DentPosted on 2007-08-29 at 08:02:53ID: 19791971


That's actually a pretty tricky one. While you can set it using the Flags you can't enumerate or remove it in the same way.

You have to enumerate the Security Descriptor for the account to see if it's been set or not. That can get quite complex, however if you're interested in continuing there's an MSDN page on this:

http://msdn2.microsoft.com/en-us/library/aa746448.aspx

Chris

 

by: frodomanPosted on 2007-08-29 at 08:45:50ID: 19792425

I'll check that out and let you know how it goes.

 

by: frodomanPosted on 2007-08-30 at 11:05:58ID: 19802600

Hi Chris,

I think I'm tantalizingly close.  I have gotten the following code working but I *think* it is pulling back the admin user object from AD and returning admin properties.  I need to run a report for all users and I obviously don't know their passwords - do you have any idea where I'm off?

dso = GetObject("LDAP:")
oUser = dso.OpenDSObject("LDAP://bi", "--my userid--", "--my password--", 1)
oSecDesc = oUser.Get("ntSecurityDescriptor")
oACL = oSecDesc.DiscretionaryAcl

For Each oACE In oACL
  If UCase(oACE.ObjectType) = UCase(CHANGE_PASSWORD_GUID) Then
    If oACE.Trustee = "Everyone" And
       oACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
         fEveryone = True
    End If

    If oACE.Trustee = "NT AUTHORITY\SELF" And
      oACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
        fSelf = True
    End If
  End If
Next

Return (fSelf AND fEveryone)

 

by: Chris-DentPosted on 2007-08-30 at 11:21:12ID: 19802717


Hey again,

You don't need to use the username and password of the account you're binding to, only a username and password of an account with permission to read the directory (any account in the domain).

So, generally I don't use OpenDSObject method at all when running administrative queries, instead I use the GetObject for an ADSI connection using current credentials:

Set objUser = GetObject("LDAP://CN=Users Name,OU=SomeOU,DC=Domain,DC=local")

Are you looking to return all user objects from the directory as well? Or how is the current user you're getting the information for being defined?

Chris

 

by: frodomanPosted on 2007-08-30 at 13:04:59ID: 19803688

Appreciate your patience...  My ultimate goal is to produce a list of users that don't have permisson to change their password (this will go into a database as part of a larger project but for now I just want to see the list).

I began with this code (asterisks replace sensitive info):

        Dim objGroupEntry As DirectoryEntry
        Dim objSearchADAM As DirectorySearcher
        Dim objSearchResults As SearchResultCollection
        Dim objResult As SearchResult

        objSearchADAM = New DirectorySearcher(New DirectoryEntry("LDAP://bi.*******.com"))
        objSearchADAM.PropertiesToLoad.Add("samAccountName")
        objSearchADAM.PropertiesToLoad.Add("objectClass")
        objSearchADAM.Sort.PropertyName = "samAccountName"
        objSearchADAM.SearchScope = SearchScope.Subtree
        objSearchADAM.Filter = "(&(objectClass=person))"
        objSearchResults = objSearchADAM.FindAll()

        For Each objResult In objSearchResults

            objGroupEntry = objResult.GetDirectoryEntry()
            Response.Write("<br>Person: " & objGroupEntry.Properties("samAccountName").Value & "...")
            Response.Write("Control: " & objGroupEntry.Properties("userAccountControl").Value & "...")            
          '*** IS USER PERMITTED TO CHANGE THEIR PASSWORD? ***

        Next objResult

Where I want to determine if user can change their password I created a function with the code I posted previously.  This executed but returned FALSE for every user (should be roughly 50% true).

I tried changing to the code you suggested:
  objUser = GetObject("LDAP://CN=JoeUser,DC=bi,DC=local")

And this throws an error "Cannot Create ActiveX Object".  I left out the "OU" piece of it because afaik we don't do anything with it.

Does this make any sense to you?


 

by: Chris-DentPosted on 2007-08-31 at 02:13:08ID: 19806784


Hey,

I have no experience at all coding in Visual Basic, all my work is with VbScript. I'll try not to let that stop me ;)

You shouldn't need this bit at all:

  objUser = GetObject("LDAP://CN=JoeUser,DC=bi,DC=local")

As you should have a connection to the user object by virtue of this:

  objGroupEntry = objResult.GetDirectoryEntry()

If it were VbScript I'd pass through "objGroupEntry" as a parameter into the function, then access the Security Descriptor from there. e.g.:


Function UserCannotChangePassword(oUser As DirectoryEntry) As Boolean
    UserCannotChangePassword = False
   
    Dim oSecDesc As IADsSecurityDescriptor
    Dim oACL As IADsAccessControlList
    Dim oACE As IADsAccessControlEntry
    Dim fEveryone As Boolean
    Dim fSelf As Boolean
   
    fEveryone = False
    fSelf = False
   
    Set oSecDesc = oUser.Get("ntSecurityDescriptor")
    Set oACL = oSecDesc.DiscretionaryAcl
   
    For Each oACE In oACL
        If UCase(oACE.ObjectType) = UCase(CHANGE_PASSWORD_GUID) Then
            If oACE.Trustee = "Everyone" And oACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
                fEveryone = True
            End If
       
            If oACE.Trustee = "NT AUTHORITY\SELF" And oACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
                fSelf = True
            End If
        End If
    Next
   
    If fSelf And fEveryone Then
        UserCannotChangePassword = True
    Else
        UserCannotChangePassword = False
    End If
End Function


I'm not sure that'll work with VB, but it'd be fun to try :) I'm not entirely sure of the difference between an object of type IADS and a DirectoryEntry. Could you give it a try?

Chris


 

by: frodomanPosted on 2007-08-31 at 06:28:43ID: 19807904

Chris - That did it.  A few tweaks to make it .Net compatible and it is now working perfectly - thanks so much for the help! - frodoman

For any future readers the following .Net code produces the output desired:
=======================================================

Imports System.DirectoryServices
Imports ActiveDs

Protected Sub Page_Load(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles Me.Load

  Dim objGroupEntry As DirectoryEntry
  Dim objSearchADAM As DirectorySearcher
  Dim objSearchResults As SearchResultCollection
  Dim objResult As SearchResult
  Dim bLockedPWord As Boolean

  objSearchADAM = New DirectorySearcher(New _
    DirectoryEntry("LDAP://DOMAIN.COMPANY.com"))
  objSearchADAM.PropertiesToLoad.Add("samAccountName")
  objSearchADAM.PropertiesToLoad.Add("objectClass")
  objSearchADAM.Sort.PropertyName = "samAccountName"
  objSearchADAM.SearchScope = SearchScope.Subtree
  objSearchADAM.Filter = "(&(objectClass=person))"
  objSearchResults = objSearchADAM.FindAll()

  For Each objResult In objSearchResults
    objGroupEntry = objResult.GetDirectoryEntry()
    Response.Write("Account: " & objGroupEntry.Properties _
      ("samAccountName").Value & "...")
    bUserCantChangePWord = IsPWordLocked(objGroupEntry)
    Response.Write("Password Flag: " & bLockedPWord & "<br>")
  Next objResult
  Response.Flush()

End Sub

Function IsPWordLocked(ByVal oUser As DirectoryEntry) As Boolean

  Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
  Const CHANGE_PASSWORD_GUID = _
             "{AB721A53-1E2F-11D0-9819-00AA0040529B}"

  Dim oSecDesc As IADsSecurityDescriptor
  Dim oACL As IADsAccessControlList
  Dim oACE As IADsAccessControlEntry
  Dim fEveryone As Boolean = False
  Dim fSelf As Boolean = False

  oSecDesc = oUser.InvokeGet("ntSecurityDescriptor")
  oACL = oSecDesc.DiscretionaryAcl

  For Each oACE In oACL
    If UCase(oACE.ObjectType) = UCase(CHANGE_PASSWORD_GUID) Then
      If oACE.Trustee = "Everyone" And oACE.AceType = _
                       ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
        fEveryone = True
      End If

      If oACE.Trustee = "NT AUTHORITY\SELF" And oACE.AceType = _
                       ADS_ACETYPE_ACCESS_DENIED_OBJECT Then
        fSelf = True
      End If
    End If
  Next

  Return (fSelf And fEveryone)
End Function


 

by: Chris-DentPosted on 2007-08-31 at 06:51:30ID: 19808112


Great stuff, I'm glad you got it working :)

Chris

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...