VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Net User Information

by Peter Elisa Souhoka (21 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 17th July 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Net User Information

Rate Net User Information



   DomainName As String, _
  GroupName As String) As Boolean
'=================================================
'=================================================
'   Purpose:    To determin if a user is a member of a specified group
'
'   Syntax:     IsGroupMember(User Name, Domain Name, Group Name)
'
'   Arguments:
'               username        -- login ID of user to verify
'               DomainName      -- Domain name the user and group reside in
'                (Can also use IP Address of Primary Domain Controller)
'               GroupName       -- NT Group name to match the user to
'
'   Example:    IsGroupMember("myusername", "mydomain", "mygroupname")
'==========================================================
'==========================================================
    Dim usr As IADsUser, obj As Object, sOut() As String, i As Long
    IsGroupMember = False
    Set usr = GetObject("WinNT://" & DomainName & "/" & Username & ",user")
    For Each obj In usr.Groups
        If GroupName = obj.Name Then IsGroupMember = True
    Next
End Function


Function IsGoodPWD(sUserName As String, DomainName As String, _
  chkPassword As String) As Boolean
'====================================================
'=====================================================
'   Purpose:    To determin if a password given is the correct network password for the specified user
'
'   Syntax:     IsGoodPWD(User Name, Domain Name, Password)
'
'   Arguments:
'               username        -- login ID of user to verify
'               DomainName      -- Domain name the user and group reside in
'                           (Can also use IP Address of Primary Domain Controller)
'               chkPassword     -- Password to verify against the domain
'
'   Example:    IsGoodPWD("myusername", "mydomain", "mypass123")
'==============================================================
'=========================================================
On Error GoTo MyError:
    Dim usr As IADsUser
    Set usr = GetObject("WinNT://" & DomainName & "/" & sUserName & ",user")
    usr.ChangePassword chkPassword, "qinspwue4"
    usr.ChangePassword "qinspwue4", chkPassword
    IsGoodPWD = True
    Exit Function
MyError:
    IsGoodPWD = False
End Function


Public Function ShowGroupMembers(DomainName As String, _
   UserGroupName As String)
'=========================================================
'=========================================================
'   Purpose:    To display the members of a specified user group
'
'   Syntax:     ShowGroupMembers(Domain Name, User Group Name)
'
'   Arguments:
'               DomainName      -- Domain name the user and group reside in
'                            (Can also use IP Address of Primary Domain Controller)
'               UserGroupName   -- The name of the NT User Group
'
'   Example:    Call ShowGroupMembers("mydomain", "mygroupname")
'============================================================
'============================================================
    Dim grp As IADsGroup, User As Object
    Set grp = GetObject("WinNT://" & DomainName & "/" & UserGroupName & "")
    For Each User In grp.members
            Debug.Print User.Name
    Next User
End Function


Download this snippet    Add to My Saved Code

Net User Information Comments

No comments have been posted about Net User Information. Why not be the first to post a comment about Net User Information.

Post your comment

Subject:
Message:
0/1000 characters