VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Check if account is disabled unsing ADSI

by Anonymous (267 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 7th September 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Check if account is disabled unsing ADSI

Rate Check if account is disabled unsing ADSI



' This file is part of the ActiveXperts Network Monitor installation
' See also http://www.activexperts.com
'
' You can write your own functions and them to this file.
' Use the following guidelines when writing a new function:
'   - The routine must be a Function, not a Sub;
'   - The Function must return True (-1), False (0) or Unknown (1);
'   - Optionally, use the EXPLANATION system variable to add your own
'     explanation to the result of the function;
'   - All variables must be 'dimmed', except EXPLANATION. EXPLANATION is an
'     ActiveXperts Network Server Monitor system variable and is already dimmed
'     by the ActiveXperts Network Server Monitor service.
'
' Prototype:
'   Function MyFunc( var1, var2, ..., varn )
'       ' Own stuff
'       MyFunc = True  ' or False (0) or Unknown (1)
'       EXPLANATION = "MyFunc returns True"
'   End Function
'
' Visit http://www.activexperts.com/activmonitor/windowsmanagement to find
' lots of samples. Use these sample as a base for new Functions.


Option Explicit


' Note: A Monitor function can return True, False or Unknown
' True and False are already defined by Visual Basic Engine
' Define the Unknown return value. This value can be any value > 0

Const retvalUnknown = 1



//


Function CheckAccountDisabled( strDomain, strAccount )
On Error Resume Next
    Dim objUser

    Set objUser = GetObject("WinNT://" & strDomain & "/" & strAccount & ",user")
    If( Err.Number <> 0 ) Then
        CheckAccountDisabled = retvalUnknown
        EXPLANATION = "Account '" & strDomain & "\" & strAccount & "' could not be found"
        Exit Function 
    End If

    If( objUser.AccountDisabled ) Then
CheckAccountDisabled = True
        EXPLANATION = "Account '" & objUser.Name & "' is disabled"
    Else
        CheckAccountDisabled = False
        EXPLANATION = "Account '" & objUser.Name & "' is enabled"
    End If
End Function 

Download this snippet    Add to My Saved Code

Check if account is disabled unsing ADSI Comments

No comments have been posted about Check if account is disabled unsing ADSI. Why not be the first to post a comment about Check if account is disabled unsing ADSI.

Post your comment

Subject:
Message:
0/1000 characters