.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification