by Paul Farrington (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 5th December 2004
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Allows to retrieve information from an NT user account, also allows to set information, such as homedirectory, profile and so on.... Simply
'Code Type : Module - FREEWARE
'Date : 07 / 05 /2004
Dim s_UserName As String
Dim s_Domain As String
Dim s_Setting As String
Dim i_InfoReq As Integer
Dim i_SetReq As Integer
Public Function GetNTACCInfo(s_UserName As String, s_Domain As String, i_InfoReq As Integer) As String
'Function Desc : This Function retrieves various aspects of a specified NT Account within an NT
' Domain, the person running this function must have access rights to access this
' information.
'
'Return Codes : If all is ok, the desired information is returned, else an error description is returned
'
'Usage : s_Return=GetNTACCInfo("paulf","mydomain",3)
' OR
' s_Return=GetNTACCInfo(s_Username,s_Domain,i_InfoReq)
'
's_UserName : Holds the UserName of who we are going to retrieve details for
's_Domain : The Domain the UserName resides in
'i_InfoReq : The type of information we are requesting
' 1 Last Login Date & Time
' 2 Password Age
' 3 Login Script
' 4 Description
' 5 Home Directory
' 6 Profile
If i_InfoReq = 0 Then
GetNTACCInfo = "The Information Request was invalid"
Exit Function
End If
On Error Resume Next
Set User = GetObject("WinNT://" & s_Domain & "/" & s_UserName)
If Err.Number <> 0 Then
GetNTACCInfo = "An Error Occurred connecting to the User Account " & Err.Number & " " & Err.Description
Set User = Nothing
Exit Function
End If
Err.Clear
Select Case i_InfoReq
Case Is = 1
GetNTACCInfo = User.LastLogin
Case Is = 2
GetNTACCInfo = User.PasswordAge
Case Is = 3
GetNTACCInfo = User.loginscript
Case Is = 4
GetNTACCInfo = User.Description
Case Is = 5
GetNTACCInfo = User.HomeDirectory
Case Is = 6
GetNTACCInfo = User.IsAccountLocked
Case Is = 7
GetNTACCInfo = User.Profile
End Select
If Err.Number <> 0 Then GetNTACCInfo = "An Error Occurred getting information form the account " & Err.Number & " " & Err.Description
Set User = Nothing
End Function
Public Function SetNTACCInfo(s_UserName As String, s_Domain As String, i_SetReq As Integer, s_Setting As String) As String
'Function Desc : This Function allows you to set various aspects of a given users
' NT Account, you must have the relevant access rights on the domain
' to be able to execute this function
'
'Return Codes : If all is ok 0 is returned, else a description of the error is returned
'
'Usage : s_Return=SetNTACCInfo("paulf","mydomain",3,"Login.bat")
' OR
' s_return=SetNTACCInfo(s_Username,s_Domain,i_SetReq,s_Setting)
'
's_UserName : Holds the UserName of who we are going to retrieve details for
's_Domain : The Domain the UserName resides in
's_Setting : The Information to set
'i_SetReq : The type of information we are configuring
' 3 Login Script
' 4 Description
' 5 Home Directory
' 6 Profile
If i_SetReq = 0 Then
SetNTACCInfo = "The Information Request was invalid"
Exit Function
End If
On Error Resume Next
Set User = GetObject("WinNT://" & s_Domain & "/" & s_UserName)
If Err.Number <> 0 Then
SetNTACCInfo = "An Error Occurred connecting to the User Account " & Err.Number & " " & Err.Description
Set User = Nothing
Exit Function
End If
Err.Clear
Select Case i_SetReq
Case Is = 3
User.loginscript = s_Setting
Case Is = 4
User.Description = s_Setting
Case Is = 5
User.HomeDirectory = s_Setting
Case Is = 6
User.Profile = s_Setting
End Select
User.SetInfo
Set User = Nothing
If Err.Number <> 0 Then
SetNTACCInfo = Err.Number & Err.Description
Else
SetNTACCInfo = "0"
End If
End Function
No comments have been posted about Allows to retrieve information from an NT user account, also allows to set information, such as hom. Why not be the first to post a comment about Allows to retrieve information from an NT user account, also allows to set information, such as hom.