Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.Net and AD

Status
Not open for further replies.

JackSkellington

Technical User
Jul 28, 2005
86
GB
I have the current code but it doesn't seem to work i.e. the account disabled message box always appears any ideas?

Code:
    Private Function CheckAccountStatus()

        Dim objEntry As DirectoryEntry
        Dim targetUser As DirectoryEntry
        Dim result As SearchResult
        Dim flags As Int16

        Try
            ' get root Organisational Unit
            objEntry = getRootDirectoryEntrySOU()
            ' find User
            Dim searcher As New DirectorySearcher(objEntry)

            searcher.Filter = "(SAMAccountName=800001)"
            searcher.CacheResults = False

            result = searcher.FindOne

            targetUser = result.GetDirectoryEntry

            With targetUser

                flags = .Properties("UserAccountControl").Value

                If flags And &H10 <> 0 Then
                    MessageBox.Show("I am disabled")

                End If

            End With

            'targetUser.CommitChanges()

        Catch excp As Exception
            clsLoggingMessage.LogException(Log, excp)
            MessageBox.Show("An error occured retrieving supplier users account status in active directory", "Maintain Organisations", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

        objEntry.Dispose()
        targetUser.Dispose()

    End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top