Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# - Channel already registered Pin
deceptionuk9-Feb-05 9:36
deceptionuk9-Feb-05 9:36 
GeneralRe: C# - Channel already registered Pin
Judah Gabriel Himango9-Feb-05 10:16
sponsorJudah Gabriel Himango9-Feb-05 10:16 
GeneralRe: C# - Channel already registered Pin
deceptionuk9-Feb-05 10:26
deceptionuk9-Feb-05 10:26 
GeneralRe: C# - Channel already registered Pin
Judah Gabriel Himango9-Feb-05 10:57
sponsorJudah Gabriel Himango9-Feb-05 10:57 
GeneralRe: C# - Channel already registered Pin
Scott Serl9-Feb-05 12:22
Scott Serl9-Feb-05 12:22 
Generalstrings Pin
John L. DeVito9-Feb-05 9:01
professionalJohn L. DeVito9-Feb-05 9:01 
GeneralRe: strings Pin
chunyu.net9-Feb-05 9:07
chunyu.net9-Feb-05 9:07 
GeneralRe: strings Pin
S. Senthil Kumar9-Feb-05 9:10
S. Senthil Kumar9-Feb-05 9:10 
GeneralRe: strings Pin
Christian Graus9-Feb-05 9:33
protectorChristian Graus9-Feb-05 9:33 
GeneralRe: strings Pin
Jon Sagara9-Feb-05 10:41
Jon Sagara9-Feb-05 10:41 
GeneralRe: strings Pin
John L. DeVito9-Feb-05 10:47
professionalJohn L. DeVito9-Feb-05 10:47 
GeneralRe: strings Pin
MoustafaS9-Feb-05 12:18
MoustafaS9-Feb-05 12:18 
GeneralRe: strings Pin
Dave Kreskowiak9-Feb-05 17:04
mveDave Kreskowiak9-Feb-05 17:04 
GeneralSystem.Diagnostics.Process memory issue Pin
chunyu.net9-Feb-05 7:11
chunyu.net9-Feb-05 7:11 
GeneralRe: System.Diagnostics.Process memory issue Pin
S. Senthil Kumar9-Feb-05 8:41
S. Senthil Kumar9-Feb-05 8:41 
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 

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.