Click here to Skip to main content
15,918,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: Equivalent of Delay in C#? Pin
Gregg Holter15-Feb-05 18:31
Gregg Holter15-Feb-05 18:31 
Generalaccessing database using webservice Pin
ronin177015-Feb-05 15:57
ronin177015-Feb-05 15:57 
GeneralRe: accessing database using webservice Pin
Kodanda Pani15-Feb-05 18:07
Kodanda Pani15-Feb-05 18:07 
GeneralRe: accessing database using webservice Pin
padvit15-Feb-05 20:10
padvit15-Feb-05 20:10 
Questionmemory leaks? Pin
15-Feb-05 15:32
suss15-Feb-05 15:32 
AnswerRe: memory leaks? Pin
S. Senthil Kumar15-Feb-05 18:28
S. Senthil Kumar15-Feb-05 18:28 
GeneralRe: memory leaks? Pin
TheSnakeByte15-Feb-05 20:03
TheSnakeByte15-Feb-05 20:03 
GeneralGet user groups of an authenticated domain user Pin
Hong Dat Huynh15-Feb-05 15:01
Hong Dat Huynh15-Feb-05 15:01 
My application allows user to authenticate to a remote share using domain loggon by invoking mpr.dll

[DllImport("mpr", CharSet=CharSet.Auto)]<br />
public static extern int WNetAddConnection2(<br />
    ref NETRESOURCE lpNetResource,<br />
    [MarshalAs(UnmanagedType.LPTStr)]<br />
    string lpPassword,<br />
    [MarshalAs(UnmanagedType.LPTStr)]<br />
    string lpUserName,<br />
    int dwFlags<br />
    );


For example I logged on using following user name: "DOMAIN_1/USERNAME_1".

I would like to find out the user groups (Administrators/Users/etc. ) of user USERNAME_1 within DOMAIN_1.

Could anyone please suggest how to do that?

I have tried using NetUserGetLocalGroups() (netapi32.dll) function but it only retrieved the user groups of USERNAME_1 in the local machine, not in the domain DOMAIN_1. I've tried NetUserGetGroups() too but don't know how to set the parameters to get it right. Please help.

[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
		public static extern int NetApiBufferFree(<br />
			out IntPtr bufptr		<br />
			);<br />
<br />
		[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
		public static extern int NetUserGetLocalGroups(<br />
			[MarshalAs(UnmanagedType.LPWStr)]<br />
			string servername,<br />
			[MarshalAs(UnmanagedType.LPWStr)]<br />
			string username,<br />
			int level,<br />
			int flags,<br />
			out IntPtr bufptr,<br />
			int prefmaxlen,<br />
			out int entriesread,<br />
			out int totalentries<br />
			);<br />
<br />
<br />
		public static ArrayList GetUserGroups(string serverAddress, string userName)//, IniGroupList iniGroupList)<br />
		{<br />
			<br />
			ArrayList groupNames = new ArrayList();<br />
			int entriesRead = 0;<br />
			int totalEntries = 0;<br />
	<br />
			IntPtr bufPtr;<br />
<br />
			int errorInfo = NetUserGetLocalGroups(serverAddress,userName,0,LG_INCLUDE_INDIRECT,<br />
				out bufPtr,MAX_PREFERRED_LENGTH,out entriesRead,out totalEntries);<br />
<br />
	<br />
			<br />
			if(entriesRead> 0)<br />
			{<br />
				LOCALGROUP_USERS_INFO_0[] RetGroups = new LOCALGROUP_USERS_INFO_0[entriesRead];<br />
				IntPtr iter = bufPtr;<br />
				for(int i=0; i < entriesRead; i++)<br />
				{<br />
					RetGroups[i] = (LOCALGROUP_USERS_INFO_0)Marshal.PtrToStructure(iter, typeof(LOCALGROUP_USERS_INFO_0)); <br />
					iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LOCALGROUP_USERS_INFO_0)));<br />
					groupNames.Add(RetGroups[i].groupname);<br />
				}<br />
				int error = NetApiBufferFree(out bufPtr);<br />
				//error = NetApiBufferFree(out iter);<br />
			}<br />
<br />
			if (errorInfo != NERR_Success)<br />
			{	<br />
				int error = NetApiBufferFree(out bufPtr);     			<br />
			}<br />
<br />
			return groupNames;<br />
		}

GeneralRe: Get user groups of an authenticated domain user Pin
Mazdak15-Feb-05 23:17
Mazdak15-Feb-05 23:17 
GeneralRe: Get user groups of an authenticated domain user Pin
Scott Serl16-Feb-05 8:13
Scott Serl16-Feb-05 8:13 
GeneralRemove Hyperlink attribute from DataGrid in C# Pin
Vipul Mehta15-Feb-05 14:45
Vipul Mehta15-Feb-05 14:45 
GeneralRemove Hyperlink attribute from DataGrid in C# Pin
Vipul Mehta15-Feb-05 14:45
Vipul Mehta15-Feb-05 14:45 
QuestionEvil 'Show Desktop' or drawing on the Desktop? Pin
TyronX15-Feb-05 13:57
TyronX15-Feb-05 13:57 
AnswerRe: Evil 'Show Desktop' or drawing on the Desktop? Pin
TyronX16-Feb-05 8:13
TyronX16-Feb-05 8:13 
Generalreturning values from a thread Pin
IsaacB15-Feb-05 12:03
IsaacB15-Feb-05 12:03 
GeneralRe: returning values from a thread Pin
DougW4815-Feb-05 16:39
DougW4815-Feb-05 16:39 
GeneralRe: returning values from a thread Pin
S. Senthil Kumar15-Feb-05 18:30
S. Senthil Kumar15-Feb-05 18:30 
GeneralReading True Color image in C# Pin
tota_115-Feb-05 11:38
tota_115-Feb-05 11:38 
GeneralRe: Reading True Color image in C# Pin
Christian Graus15-Feb-05 11:47
protectorChristian Graus15-Feb-05 11:47 
GeneralC# and SystemTimeToTzSpecificLocalTime Pin
tomsmbox-codeproject15-Feb-05 11:17
tomsmbox-codeproject15-Feb-05 11:17 
Generalg the thread Pin
Sasuko15-Feb-05 11:03
Sasuko15-Feb-05 11:03 
GeneralArray Of Constants Pin
DTWC_Lawrence15-Feb-05 10:38
DTWC_Lawrence15-Feb-05 10:38 
GeneralRe: Array Of Constants Pin
S. Senthil Kumar15-Feb-05 11:00
S. Senthil Kumar15-Feb-05 11:00 
GeneralRe: Array Of Constants Pin
DTWC_Lawrence15-Feb-05 11:13
DTWC_Lawrence15-Feb-05 11:13 
Questionproject-to-project references ??? Pin
Anonymous15-Feb-05 9:54
Anonymous15-Feb-05 9:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.