LeeSalter
Active member
Hi All,
Ill apologise in advance for the length of this post.
I am trying to get information about any given user on our NT 4 Domain/Network.
I have defined the USER_INFO_3 structure like this:-
..and am declaring the API like this:-
..I am calling the API like this from my code:-
The API returns with code zero, indicating that it has completed successfully. This is confirmed by the fact that it fails when I pass it a non-existent user.
However, the structure is not populating with any data whatosever.
Does anybody know what I am doing wrong? Do I need to use the marshal.ptrToStructure or marshal.StructureToPtr methods anywhere??
Any help would be appreciated.
Ill apologise in advance for the length of this post.
I am trying to get information about any given user on our NT 4 Domain/Network.
I have defined the USER_INFO_3 structure like this:-
Code:
<StructLayout(LayoutKind.Sequential)> _
Public Structure USER_INFO_3
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_name As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_password As String
Public usri3_password_age As Integer
Public usri3_priv As Integer
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_home_dir As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_comment As String
Public usri3_flags As Integer
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_script_path As String
Public usri3_auth_flags As Integer
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_full_name As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_usr_comment As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_parms As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_workstations As String
Public usri3_last_logon As Integer
Public usri3_last_logoff As Integer
Public usri3_acct_expires As Integer
Public usri3_max_storage As Integer
Public usri3_units_per_week As Integer
<MarshalAs(UnmanagedType.U1)> Public usri3_logon_hours As Byte
Public usri3_bad_pw_count As Integer
Public usri3_num_logons As Integer
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_logon_server As String
Public usri3_country_code As Integer
Public usri3_code_page As Integer
Public usri3_user_id As Integer
Public usri3_primary_group_id As Integer
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_profile As String
<MarshalAs(UnmanagedType.LPWStr)> Public usri3_home_dir_drive As String
Public usri3_password_expired As Integer
End Structure
..and am declaring the API like this:-
Code:
Public Declare Unicode Function NetUserGetInfo Lib "netapi32" _
(ByRef lpServer As Byte, _
ByRef UserName As Byte, _
ByVal Level As Integer, ByVal lpBuffer As IntPtr) As Integer
..I am calling the API like this from my code:-
Code:
lRet = NetUserGetInfo(ServerName(0), UserName(0), Level, lpBuf)
The API returns with code zero, indicating that it has completed successfully. This is confirmed by the fact that it fails when I pass it a non-existent user.
However, the structure is not populating with any data whatosever.
Does anybody know what I am doing wrong? Do I need to use the marshal.ptrToStructure or marshal.StructureToPtr methods anywhere??
Any help would be appreciated.