473,659 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access .NET thread to get Principal / Identity ?

is that possible from a C++ app?
thank you. -Greg
Nov 17 '05 #1
11 2206
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
is that possible from a C++ app?
thank you.


It is not all that clear what you want to do. Which thread are you talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will
Nov 17 '05 #2
Thank you for responding Will. Sorry for not offering more detail.

I have the following .NET C# code using .NET System.Security .Principal;

m_iIdnt = new System.Security .Principal.Gene ricIdentity(t.U serName,"custom
authentication" );
m_iPrincipal = new
System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;

What I would like to do is access the Identity from what happened above, but
from a C++ app rather than the following .NET app;

IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
IIdentity currentIdentity = currentPrincipa l.Identity;
string authtype = currentIdentity .Authentication Type;
if (currentIdentit y.IsAuthenticat ed) .........

thank you,
Greg

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
is that possible from a C++ app?
thank you.


It is not all that clear what you want to do. Which thread are you talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will

Nov 17 '05 #3
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Thank you for responding Will. Sorry for not offering more detail.

I have the following .NET C# code using .NET System.Security .Principal;

m_iIdnt = new
System.Security .Principal.Gene ricIdentity(t.U serName,"custom
authentication" );
m_iPrincipal = new
System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;

What I would like to do is access the Identity from what happened above,
but
from a C++ app rather than the following .NET app;

IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
IIdentity currentIdentity = currentPrincipa l.Identity;
string authtype = currentIdentity .Authentication Type;
if (currentIdentit y.IsAuthenticat ed) .........

thank you,
Greg

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
> is that possible from a C++ app?
> thank you.


It is not all that clear what you want to do. Which thread are you
talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will


Nov 17 '05 #4
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Thank you for responding Will. Sorry for not offering more detail.

I have the following .NET C# code using .NET System.Security .Principal;

m_iIdnt = new
System.Security .Principal.Gene ricIdentity(t.U serName,"custom
authentication" );
m_iPrincipal = new
System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;

What I would like to do is access the Identity from what happened above,
but
from a C++ app rather than the following .NET app;

IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
IIdentity currentIdentity = currentPrincipa l.Identity;
string authtype = currentIdentity .Authentication Type;
if (currentIdentit y.IsAuthenticat ed) .........

thank you,
Greg

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
> is that possible from a C++ app?
> thank you.


It is not all that clear what you want to do. Which thread are you
talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will


Nov 17 '05 #5
I understand. But is there an interop possibility?

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:eD******** ******@TK2MSFTN GP09.phx.gbl...
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Thank you for responding Will. Sorry for not offering more detail.

I have the following .NET C# code using .NET System.Security .Principal;

m_iIdnt = new
System.Security .Principal.Gene ricIdentity(t.U serName,"custom
authentication" );
m_iPrincipal = new
System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;

What I would like to do is access the Identity from what happened above,
but
from a C++ app rather than the following .NET app;

IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
IIdentity currentIdentity = currentPrincipa l.Identity;
string authtype = currentIdentity .Authentication Type;
if (currentIdentit y.IsAuthenticat ed) .........

thank you,
Greg

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
> is that possible from a C++ app?
> thank you.

It is not all that clear what you want to do. Which thread are you
talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will



Nov 17 '05 #6
I understand. But is there an interop possibility?

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:eD******** ******@TK2MSFTN GP09.phx.gbl...
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Thank you for responding Will. Sorry for not offering more detail.

I have the following .NET C# code using .NET System.Security .Principal;

m_iIdnt = new
System.Security .Principal.Gene ricIdentity(t.U serName,"custom
authentication" );
m_iPrincipal = new
System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;

What I would like to do is access the Identity from what happened above,
but
from a C++ app rather than the following .NET app;

IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
IIdentity currentIdentity = currentPrincipa l.Identity;
string authtype = currentIdentity .Authentication Type;
if (currentIdentit y.IsAuthenticat ed) .........

thank you,
Greg

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
"hazz" <ha**@sonic.net > wrote in message
news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
> is that possible from a C++ app?
> thank you.

It is not all that clear what you want to do. Which thread are you
talking
about?

Both dialects of C++ (managed and unmanaged) have no trouble calling
functions of the Win32 API. In particular, calling GetUserName() and
LookupAccountNa me() might take you where you want to go.

Regards,
Will



Nov 17 '05 #7
Sure, you can expose your C# class as COM object and use COM interop,
question is why would you do that when simply calling the Win32 API's gives
you the same information.

Willy.
"hazz" <ha**@sonic.net > wrote in message
news:Ou******** ******@TK2MSFTN GP09.phx.gbl...
I understand. But is there an interop possibility?

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:eD******** ******@TK2MSFTN GP09.phx.gbl...
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
> Thank you for responding Will. Sorry for not offering more detail.
>
> I have the following .NET C# code using .NET System.Security .Principal;
>
> m_iIdnt = new
> System.Security .Principal.Gene ricIdentity(t.U serName,"custom
> authentication" );
> m_iPrincipal = new
> System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
> System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;
>
> What I would like to do is access the Identity from what happened
> above,
> but
> from a C++ app rather than the following .NET app;
>
> IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
> IIdentity currentIdentity = currentPrincipa l.Identity;
> string authtype = currentIdentity .Authentication Type;
> if (currentIdentit y.IsAuthenticat ed) .........
>
> thank you,
> Greg
>
> "William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
> news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
>> "hazz" <ha**@sonic.net > wrote in message
>> news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
>> > is that possible from a C++ app?
>> > thank you.
>>
>> It is not all that clear what you want to do. Which thread are you
>> talking
>> about?
>>
>> Both dialects of C++ (managed and unmanaged) have no trouble calling
>> functions of the Win32 API. In particular, calling GetUserName() and
>> LookupAccountNa me() might take you where you want to go.
>>
>> Regards,
>> Will
>>
>>
>
>



Nov 17 '05 #8
Sure, you can expose your C# class as COM object and use COM interop,
question is why would you do that when simply calling the Win32 API's gives
you the same information.

Willy.
"hazz" <ha**@sonic.net > wrote in message
news:Ou******** ******@TK2MSFTN GP09.phx.gbl...
I understand. But is there an interop possibility?

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:eD******** ******@TK2MSFTN GP09.phx.gbl...
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
> Thank you for responding Will. Sorry for not offering more detail.
>
> I have the following .NET C# code using .NET System.Security .Principal;
>
> m_iIdnt = new
> System.Security .Principal.Gene ricIdentity(t.U serName,"custom
> authentication" );
> m_iPrincipal = new
> System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
> System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;
>
> What I would like to do is access the Identity from what happened
> above,
> but
> from a C++ app rather than the following .NET app;
>
> IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
> IIdentity currentIdentity = currentPrincipa l.Identity;
> string authtype = currentIdentity .Authentication Type;
> if (currentIdentit y.IsAuthenticat ed) .........
>
> thank you,
> Greg
>
> "William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
> news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
>> "hazz" <ha**@sonic.net > wrote in message
>> news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
>> > is that possible from a C++ app?
>> > thank you.
>>
>> It is not all that clear what you want to do. Which thread are you
>> talking
>> about?
>>
>> Both dialects of C++ (managed and unmanaged) have no trouble calling
>> functions of the Win32 API. In particular, calling GetUserName() and
>> LookupAccountNa me() might take you where you want to go.
>>
>> Regards,
>> Will
>>
>>
>
>



Nov 17 '05 #9
Thanks Willy for helping me out here. One more outrageous question. Can I
access the .NET runtime thread using Win32 API's. (which contains the
Principal and Identity that I want) thx. -greg the newbie

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:uV******** *****@TK2MSFTNG P12.phx.gbl...
Sure, you can expose your C# class as COM object and use COM interop,
question is why would you do that when simply calling the Win32 API's gives you the same information.

Willy.
"hazz" <ha**@sonic.net > wrote in message
news:Ou******** ******@TK2MSFTN GP09.phx.gbl...
I understand. But is there an interop possibility?

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:eD******** ******@TK2MSFTN GP09.phx.gbl...
The FCL classes are only usable in a managed C++ application, native C++ cannot use managed classes.

Willy.

"hazz" <ha**@sonic.net > wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
> Thank you for responding Will. Sorry for not offering more detail.
>
> I have the following .NET C# code using .NET System.Security .Principal; >
> m_iIdnt = new
> System.Security .Principal.Gene ricIdentity(t.U serName,"custom
> authentication" );
> m_iPrincipal = new
> System.Security .Principal.Gene ricPrincipal(m_ iIdnt,roles);
> System.Threadin g.Thread.Curren tPrincipal=m_iP rincipal;
>
> What I would like to do is access the Identity from what happened
> above,
> but
> from a C++ app rather than the following .NET app;
>
> IPrincipal currentPrincipa l = Thread.CurrentP rincipal;
> IIdentity currentIdentity = currentPrincipa l.Identity;
> string authtype = currentIdentity .Authentication Type;
> if (currentIdentit y.IsAuthenticat ed) .........
>
> thank you,
> Greg
>
> "William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
> news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
>> "hazz" <ha**@sonic.net > wrote in message
>> news:Ob******** ******@TK2MSFTN GP12.phx.gbl...
>> > is that possible from a C++ app?
>> > thank you.
>>
>> It is not all that clear what you want to do. Which thread are you
>> talking
>> about?
>>
>> Both dialects of C++ (managed and unmanaged) have no trouble calling
>> functions of the Win32 API. In particular, calling GetUserName() and
>> LookupAccountNa me() might take you where you want to go.
>>
>> Regards,
>> Will
>>
>>
>
>



Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1401
by: Robert Phillips | last post by:
I periodically get an ApplicationException "access is denied" in the WindowsIdentity._GetCurrentToken() method. Reflector shows the _GetCurrentToken() method as private static extern IntPtr _GetCurrentToken(); which i believe means it is an internal call into the CLR.Does anyone have any thoughts on why this would be happening?
5
1805
by: Mats-Lennart Hansson | last post by:
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
2
349
by: hazz | last post by:
is that possible from a C++ app? thank you. -Greg
3
7248
by: David B. Bitton | last post by:
For some odd reason, despite the fact that I assign my own custom IPrincipal to the HttpContext.User property in an HttpApplication.AuthenticateRequest event handler inside of an IHttpModule, when I check the Page.User property, it's a WindowsPrincipal and not _my_ custom Iprincipal. Why would this be? .... using System;
2
391
by: Stan | last post by:
I start a new thread to run a long database query and show the progress bar Thread DbThread = new Thread(new ThreadStart(dr.GetDataFromDb)); DbThread.Start() Response.Redirect ("WaitPage.aspx") Problem is that the new thread ignores the identity of asp_netwp.exe worker process. There is <identity impersonate="true" /> in the web.config and I use integrated SQL Security, that is the identity of the anonymous account in IIS metabase. ...
1
4882
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is denied. Here is the server setup that we have: Dev - Development Computer on WinXP Pro SP2 (IIS5), VS2003 developing under .NET Framework 1.1 Server1 - Web Server on Win2003 Server (IIS6) Server2 - File Server on Win2003 Server
11
1826
by: Eric | last post by:
Hello, I have a web app that uploads files to a file server (different box than the web server). The application uses NT integrated authentication, but no users should have permissions to the file server. How can I use a fixed domain account to upload the files to the file server while still preserving the users' Windows integrated authentication on the web server?
2
3788
by: Shailesh Gajare | last post by:
Hi All, I have creating an ASP.Net application with two web servers. I am uploading a file which is being uploaded on one of the server, I want to copy the uploaded file on the other server at the same time. It says Access Denied. I am using File.Copy ( Source , Destination , true ) command in my code, where Source : the current physical location of the uploaded file
0
1387
by: Ed Sutton | last post by:
Is there a FileSecurity method that can determine if the current WindowsIdentity has write access to a file? I can get the current windows identity and use FileSecurity to return the AuthorizationRuleCollection and then search for the FileSystemAccessRule's that apply to my identity. The problem is my current identity may be "MYDOMAIN\JDOE", but I do not know how to determine if a group this identity belongs, for example "EVERYONE",...
0
8427
marktang
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...
0
8332
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,...
0
8851
Oralloy
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...
1
8525
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,...
0
8627
tracyyun
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...
0
7356
agi2029
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...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.