Hi,
I want to get the name of the owner of a thread. I have a component that can
be called from many different components so I want to trace which user that
owns the thread. Is this possible in c#?
Thanks,
Mats-Lennart 5 1804
Hi Mats:
You can inspect the static CurrentPrincipa l property of the Thread
class.
--
Scott http://www.OdeToCode.com
On Tue, 31 Aug 2004 16:04:51 +0200, "Mats-Lennart Hansson"
<ap********@hot mail.com> wrote: Hi, I want to get the name of the owner of a thread. I have a component that can be called from many different components so I want to trace which user that owns the thread. Is this possible in c#?
Thanks, Mats-Lennart
Yous hould be careful with this approach, because it is very possible to
change the principal for the thread, to something completely different from
a windows user.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:g0******** *************** *********@4ax.c om... Hi Mats:
You can inspect the static CurrentPrincipa l property of the Thread class.
-- Scott http://www.OdeToCode.com
On Tue, 31 Aug 2004 16:04:51 +0200, "Mats-Lennart Hansson" <ap********@hot mail.com> wrote:
Hi, I want to get the name of the owner of a thread. I have a component that can be called from many different components so I want to trace which user that owns the thread. Is this possible in c#?
Thanks, Mats-Lennart
Try this:
WindowsPrincipa l threadPrincipal = Thread.CurrentP rincipal as
WindowsPrincipa l;
if (threadPrincipa l != null)
// Valid Windows principal
Console.WriteLi ne(threadPrinci pal.Identity.Na me);
else
// Current principal is not a Windows principal
Willy.
"Mats-Lennart Hansson" <ap********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . Hi, I want to get the name of the owner of a thread. I have a component that can be called from many different components so I want to trace which user that owns the thread. Is this possible in c#?
Thanks, Mats-Lennart
It's also possible to think you've changed the principal for a thread
without having done so (this doesn't do impersonation). The property
is for server applications to check, not really to modify.
--
Scott http://www.OdeToCode.com
On Tue, 31 Aug 2004 10:52:35 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard .caspershouse.c om> wrote: Yous hould be careful with this approach, because it is very possible to change the principal for the thread, to something completely different from a windows user.
Apologies, I thought I was in the asp.net group.
If this is a component used outside of ASP.NET use
WindowsIdentity .GetCurrent() from the System.Security .Principal
namespace.
--
Scott http://www.OdeToCode.com
On Tue, 31 Aug 2004 10:36:18 -0400, Scott Allen
<bitmask@[nospam].fred.net> wrote: Hi Mats:
You can inspect the static CurrentPrincipa l property of the Thread class. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Raed Sawalha |
last post by:
Hello:
I have 2 windows application 1st one is periodically writing specific data
to XML file , the 2nd application has a dialog with DataGrid , the datagrid
filled with information in the XML generated by 1st application and should
be updated as soon as the XML file is update, so I decide to code a
continously running thread that checks the XML every specific time and
refresh the contents of datagrid
the question :
1. How can I code a...
|
by: Raed Sawalha |
last post by:
Dear:
I used to code a continously running thread in C++ like following:
Handle hStopEvent = CreateEvent(NULL,true,false,NULL);
UINT uOptional = 0;
_beginthreadex(NULL,0,wtInvestigate,(LPVOID)NULL,0,&uOptional);
unsigned _stdcall
wtInvestigate(LPVOID lpParams)
{
|
by: Tales Normando |
last post by:
Hi,
I'm working on a cybercafe management system that uses a
homemade messaging exchange system to communicate between the server and the
client softwares. Each one of the projects spawns another thread to wait
until a new message has arrived and process it. Some of the messages require
showing an user interface, like Messagebox.Show(). My problem is, I don't
want such calls to be executed on this thread, but on the main one. What
kind...
|
by: Thomas Mueller |
last post by:
Hi,
I tried to install phpopenchat but I can't create this table:
poc=> CREATE TABLE poc_user_account (
poc(> USER varchar(255) NOT NULL,
poc(> PASSWORD varchar(255),
poc(> CONFIRM_CODE char(32),
poc(> DISABLED int NOT NULL DEFAULT '0',
poc(> KICKED int NOT NULL DEFAULT '0',
|
by: Albretch Mueller |
last post by:
I need to get the name of the very code running in order to include it in a
time stamped log file.
..
As I remember, there is an ANSI standard way to ask a running program for
its name. But I forgot the specifics of it.
..
How is it that you do that?
..
lbrtchx
| |
by: seb |
last post by:
Hi,
I am using pygtk for the first times.
I am wondering what would be the best "pattern" to interface pygtk with
a thread.
The thread is collecting informations (over the network for example) or
is doing some long calculations.
|
by: care02 |
last post by:
Hi!
I have the following problem: I have written a short Python server
that creates an indefinite simulation thread that I want to kill when
quitting (Ctrl-C) from Python. Googling around has not given me any
hints on how to cleanly kill running threads before exiting. Any help
is appreciated!
Carl
|
by: Robinychen |
last post by:
Does anyone know whether Delphi has a similar thread like the user interface thread in Visual C++ 6.0?
Thanks.
Rob
|
by: mbewers1 |
last post by:
I have a problem with this piece of code, which loads a splash screen and keeps it open for 5 seconds before loading another form.
It strangely seems to be repeatedly running a thread once the method has executed and showing an unlimited number of splash screens but no main form. I've tried inserting mb.Suspend() and mb.Abort() after requesting the ShowDialog() method to be run for my main form, Form1.
How can I stop the thread from...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |