1 |
// Douglas Thrift |
2 |
// |
3 |
// CCS Computer Science |
4 |
// |
5 |
// Win32 Network Management Wrapper |
6 |
|
7 |
using System; |
8 |
using System.Runtime.InteropServices; |
9 |
|
10 |
public static class Net |
11 |
{ |
12 |
[StructLayout(LayoutKind.Sequential)] |
13 |
public class NET_DISPLAY_USER |
14 |
{ |
15 |
[MarshalAs(UnmanagedType.LPWStr)] |
16 |
public string usri1_name; |
17 |
[MarshalAs(UnmanagedType.LPWStr)] |
18 |
public string usri1_comment; |
19 |
public uint usri1_flags; |
20 |
[MarshalAs(UnmanagedType.LPWStr)] |
21 |
public string usri1_full_name; |
22 |
public uint usri1_user_id; |
23 |
public uint usri1_next_index; |
24 |
} |
25 |
|
26 |
[StructLayout(LayoutKind.Sequential)] |
27 |
public class USER_INFO_11 |
28 |
{ |
29 |
[MarshalAs(UnmanagedType.LPWStr)] |
30 |
public string usri11_name; |
31 |
[MarshalAs(UnmanagedType.LPWStr)] |
32 |
public string usri11_comment; |
33 |
[MarshalAs(UnmanagedType.LPWStr)] |
34 |
public string usri11_usr_comment; |
35 |
[MarshalAs(UnmanagedType.LPWStr)] |
36 |
public string usri11_full_name; |
37 |
public uint usri11_priv; |
38 |
public uint usri11_auth_flags; |
39 |
public uint usri11_password_age; |
40 |
[MarshalAs(UnmanagedType.LPWStr)] |
41 |
public string usri11_home_dir; |
42 |
[MarshalAs(UnmanagedType.LPWStr)] |
43 |
public string usri11_parms; |
44 |
public uint usri11_last_logon; |
45 |
public uint usri11_last_logoff; |
46 |
public uint usri11_bad_pw_count; |
47 |
public uint usri11_num_logons; |
48 |
[MarshalAs(UnmanagedType.LPWStr)] |
49 |
public string usri11_logon_server; |
50 |
public uint usri11_country_code; |
51 |
[MarshalAs(UnmanagedType.LPWStr)] |
52 |
public string usri11_workstations; |
53 |
public uint usri11_max_storage; |
54 |
public uint usri11_units_per_week; |
55 |
public IntPtr usri11_logon_hours; |
56 |
public uint usri11_code_page; |
57 |
} |
58 |
|
59 |
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetQueryDisplayInformation")] |
60 |
public static extern uint QueryDisplayInformation([In] string ServerName, [In] uint Level, [In] uint Index, [In] uint EntriesRequested, [In] uint PreferredMaximumLength, [Out] uint ReturnedEntryCount, [Out] NET_DISPLAY_USER[] SortedBuffer); |
61 |
|
62 |
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetUserGetInfo")] |
63 |
public static extern uint UserGetInfo([In] string servername, [In] string username, [In] uint level, [Out] USER_INFO_11 bufptr); |
64 |
|
65 |
[DllImport("Netapi32.dll", EntryPoint = "NetApiBufferFree")] |
66 |
public static extern uint ApiBufferFree([In] USER_INFO_11 buffer); |
67 |
|
68 |
[DllImport("Netapi32.dll", EntryPoint = "NetApiBufferFree")] |
69 |
public static extern uint ApiBufferFree([In] NET_DISPLAY_USER[] buffer); |
70 |
} |