Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a Class library which can be used to control/Manage Asynchronous calls.It takes 4 input values
1)hostAddress
2)User Name
3)Password
4)Query(string Type)--Eg:
XML
<?xml version='1.0'?>
<wql>
    <query id='1' ns='root\cimv2'><![CDATA[ select CSName from Win32_OperatingSystem]]></query>
  <query id="2" ns="root\cimv2"><![CDATA[ select    RPCAveragedLatency from Win32_PerfRawData_MSExchangeIS_MSExchangeIS]]></query>
</wql>

I am using all possible code for WMI for Asynchronous Theading.
But I am getting "login Failed".
Please help me in this scenario.
Posted
Updated 23-Nov-10 22:24pm
v2

1 solution

Did you set the Thread.CurrentPrincipal to that of the main thread? Would be something like:

// In the main thread
System.Security.Principal.WindowsPrincipal principal = System.Threading.Thread.CurrentPrinicpal;

// Start new thread
System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(ThreadMethod);
System.Threading.Thread t = new System.Threading.Thread(threadStart);
...

protected void ThreadMethod()
{
   // Set the Thread.CurrentPrincipal
   System.Threading.Thread.CurrentPrinicpal = principal;
...


More info:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentprincipal.aspx[^]

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900