Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.Diagnostics.Process memory issue Pin
chunyu.net9-Feb-05 9:06
chunyu.net9-Feb-05 9:06 
Generalpassing char[] from c++ to c# in a web method from a lecacy c++ dll Pin
pleoncini9-Feb-05 5:49
pleoncini9-Feb-05 5:49 
GeneralListBox.TopIndex... Pin
cromag9-Feb-05 5:09
cromag9-Feb-05 5:09 
GeneralRe: ListBox.TopIndex... Pin
cromag9-Feb-05 5:17
cromag9-Feb-05 5:17 
GeneralReading Outlook Attachments using MAPI33 wrapper dll using C# Pin
keshavcn9-Feb-05 4:08
keshavcn9-Feb-05 4:08 
General.NET remoting error Pin
Member 16488299-Feb-05 3:49
Member 16488299-Feb-05 3:49 
GeneralRe: .NET remoting error Pin
S. Senthil Kumar9-Feb-05 8:43
S. Senthil Kumar9-Feb-05 8:43 
GeneralLogon User Pin
sharathgowda9-Feb-05 0:50
sharathgowda9-Feb-05 0:50 
I am Logon user to create the impresonate user. When the run the code on windows 2000 I am getting the message "A required privilege is not held by the client."

Can any one let me know what privalages has to set.

For reference I am attaching the code also.

[assembly:SecurityPermissionAttribute(SecurityAction.RequestOptional, UnmanagedCode=true)]
[assembly:PermissionSetAttribute(SecurityAction.RequestOptional, Name = "FullTrust")]

[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

[DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private unsafe static extern int FormatMessage(int dwFlags, ref IntPtr lpSource,
int dwMessageId, int dwLanguageId, ref String lpBuffer, int nSize, IntPtr *Arguments);

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);

[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,
int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);


public unsafe static string GetErrorMessage(int errorCode)
{
int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;

//int errorCode = 0x5; //ERROR_ACCESS_DENIED
//throw new System.ComponentModel.Win32Exception(errorCode);

int messageSize = 255;
String lpMsgBuf = "";
int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;

IntPtr ptrlpSource = IntPtr.Zero;
IntPtr prtArguments = IntPtr.Zero;

int retVal = FormatMessage(dwFlags, ref ptrlpSource, errorCode, 0, ref lpMsgBuf, messageSize, &prtArguments);
if (0 == retVal)
{
throw new Exception("Failed to format message for error code " + errorCode + ". ");
}

return lpMsgBuf;
}

string userName;
userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
MessageBox.Show(userName);

IntPtr tokenHandle = new IntPtr(0);
IntPtr dupeTokenHandle = new IntPtr(0);

tokenHandle = IntPtr.Zero;
dupeTokenHandle = IntPtr.Zero;

const int LOGON32_PROVIDER_DEFAULT = 0;
const int LOGON32_LOGON_INTERACTIVE = 2;

bool returnValue = LogonUser(textBox1.Text, textBox2.Text, textBox3.Text,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
ref tokenHandle);

somebody please help me
GeneralRe: Logon User Pin
Mike Dimmick9-Feb-05 2:30
Mike Dimmick9-Feb-05 2:30 
GeneralRe: Logon User Pin
sharathgowda9-Feb-05 18:46
sharathgowda9-Feb-05 18:46 
GeneralRe: Logon User Pin
Heath Stewart11-Feb-05 7:05
protectorHeath Stewart11-Feb-05 7:05 
GeneralTabcontrol - transparent Pin
Member 13542768-Feb-05 23:49
Member 13542768-Feb-05 23:49 
GeneralUI control components for .Net Pin
ppp0018-Feb-05 23:16
ppp0018-Feb-05 23:16 
GeneralRe: UI control components for .Net Pin
Colin Angus Mackay8-Feb-05 23:58
Colin Angus Mackay8-Feb-05 23:58 
Generalmapi components for .net Pin
ppp0018-Feb-05 23:13
ppp0018-Feb-05 23:13 
QuestionHow to add Check Boxes for Extra Column in a DataGrid? Pin
pubududilena8-Feb-05 20:32
pubududilena8-Feb-05 20:32 
AnswerRe: How to add Check Boxes for Extra Column in a DataGrid? Pin
Christian Graus9-Feb-05 9:37
protectorChristian Graus9-Feb-05 9:37 
Generalget URL !!!! Pin
students552 university8-Feb-05 19:41
students552 university8-Feb-05 19:41 
GeneralRe: get URL !!!! Pin
Anonymous9-Feb-05 7:13
Anonymous9-Feb-05 7:13 
GeneralRe: get URL !!!! Pin
Heath Stewart9-Feb-05 15:04
protectorHeath Stewart9-Feb-05 15:04 
GeneralRe: get URL !!!! Pin
students552 university11-Feb-05 6:54
students552 university11-Feb-05 6:54 
GeneralRe: get URL !!!! Pin
Heath Stewart11-Feb-05 7:03
protectorHeath Stewart11-Feb-05 7:03 
GeneralIContextMenu Shell Extension - HandleMenuMsg Pin
LoKi_za8-Feb-05 19:38
LoKi_za8-Feb-05 19:38 
GeneralRe: IContextMenu Shell Extension - HandleMenuMsg Pin
Wraith29-Feb-05 1:33
Wraith29-Feb-05 1:33 
GeneralRe: IContextMenu Shell Extension - HandleMenuMsg Pin
LoKi_za9-Feb-05 1:42
LoKi_za9-Feb-05 1:42 

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.