JackSkellington
Technical User
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