Search:
Namespaces
Discussions
.NET v1.1
Feedback
access .NET thread to get Principal / Identity ?
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.languages.vc
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
hazz
is that possible from a C++ app?
thank you. -Greg
Reply to this message...
William DePalo [MVP VC++] (VIP)
"hazz" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
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
LookupAccountName() might take you where you want to go.
Regards,
Will
Reply to this message...
hazz
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.
GenericIdentity
(t.UserName,"custom
authentication");
m_iPrincipal = new
System.Security.Principal.
GenericPrincipal
(m_iIdnt,roles);
System.Threading.
Thread
.CurrentPrincipal=m_iPrincipal;
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
currentPrincipal =
Thread
.CurrentPrincipal;
IIdentity
currentIdentity = currentPrincipal.Identity;
string authtype = currentIdentity.AuthenticationType;
if (currentIdentity.IsAuthenticated) .........
thank you,
Greg
"William DePalo [MVP VC++]" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Willy Denoyette [MVP] (VIP)
The FCL classes are only usable in a managed C++ application, native C++
cannot use managed classes.
Willy.
"hazz" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
hazz
I understand. But is there an interop possibility?
"Willy Denoyette [MVP]" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Willy Denoyette [MVP] (VIP)
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" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
hazz
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]" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
William DePalo [MVP VC++] (VIP)
"hazz" <
Click here to reveal e-mail address
> wrote in message
news:uS%
Click here to reveal e-mail address
...
[Original message clipped]
<note>
I am not passing on your design strategy, simply answering the question that
you asked.
</note>
You can mix unmanaged C++ and Managed Extensions fro C++ (soon to be called
C++/CLI) in the same module. So one option is to have functions free
functions in an unmanaged module call on member functions in an MC++ class
which call on the requisite functions in your C# class. This works best when
you think in terms of interfaces. Don't think of sharing managed types with
unmanaged code.
Regards,
Will
Reply to this message...
hazz
The light bulb is beginning to flicker.
.... and I acknowledge there are larger design issues here, even if I don't
understand them yet.
I am still looking for keywords and keynote concepts in the answers to my
questions.
I realize I am not asking the right questions yet.
Is CLI common language interface?
Thanks Will.
"William DePalo [MVP VC++]" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Security.Principal.GenericIdentity
System.Security.Principal.GenericPrincipal
System.Security.Principal.IIdentity
System.Security.Principal.IPrincipal
System.Threading.Thread
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com