Posts

How to retrieve the private key of a certificate?

private string PrivateKey(X509Certificate2 certificate) { string pk; if (certificate.PrivateKey != null) { RSACryptoServiceProvider rsaProvider = certificate.PrivateKey as RSACryptoServiceProvider; pk = rsaProvider.CspKeyContainerInfo.UniqueKeyContainerName; } return pk; }

Network Security: LAN manager authentication level

In windows server 2008, if we go to Network Security: LAN manager authentication level(gpedit.msc -> Computer Configuration -> WindowsSettings -> SecuritySettings LocalPolicies -> securityoptions ) and right click on it, we cannot change the value of the authentication level. It is greyed out. To change this we need to go to following registry entry.. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\LmCompatibilityLevel and set the value. LmCompatibilityLevel should be 0 for Send LM & NTLM responses 1 for Send LM & NLTM - use NTLMv2 session security if negotiated 2 for Send NTLM response only 3 for Send NTLMv2 response only 4 for Send NTLMv2 response only\refuse LM 5 for Send NTLMv2 response only\refuse LM & NTLM

Exchange Server

How to configure a HTTP endpoint for Exchange Web Services in Exchange Server? In Exchange Server 2007, what we need to do it is just uncheck Require SSL in IIS. For 2010 Exchange even after doing the above step doesnt solve the issue.. This article addresses and solves the issue clearly.. http://blogs.msdn.com/dvespa/archive/2009/12/22/how-to-configure-a-http-endpoint-for-exchange-web-services-in-exchange-2010.aspx

Windbg / ntsd Debugging commands

.load sos.dll -> Loads sos.dll which can analyze managed code !threads – shows the current threads running at the point when dump is taken !threadpool – shows the thread pool threads, queued items and timers ~*e!clrstack -> Shows the stack trace of threads !dumpheap –stat -> shows the heap memory contents !gcroot - shows all the references to managed memory in heap. If the above command does not show try the below command it gives correctly: For iterating thru gcroot .foreach (obj {!dumpheap -short -mt 0x000123ab}) {!gcroot obj} 0x000123ab – Address of the object we need to look for any references

Thread and Process

Both Threads and Processes are used for parallelisation. A thread is an independent execution path and a process contain minimum one thread. Operating system runs all our applications as processes and OS itself is a Process. Now each application(Process) can have any number of threads. Differerence between Thread and Process: Threads can share the heap memory among them. Whereas Processes are completely isolated. Then what is inter-process communication? It is the communication between threads may be of single process or different processes. And therefore it is also called inter-thread communication. Funny terminology to confuse me :@

ASP.NET page life cycle

Page Request: When the page is requested by a user, ASP.NET engine determines whether page needs to be parsed or it can directly send the page which is in control or view state. Start: At this stage, Request and Response objects are set. And in this state itself whether the request is Postback or not is set. Initialisation: : Controls on the page will be available. Matser page with the theme will be loaded if applicable. Load: If the current request is a post back, control properties are loaded from the load state or view state. Postbackeventhandling: If the request is a postback, then the relevant control event handlers will be called. And after that IsValidate is called for validating the the control values based on the request. Render: Now just before rendering the content on the page, content is loaded into view state. During this stage Render for each control is called by the page. Unload: After the page is completely rendered and sent to client, Response and Request obj...

Constant and ReadOnly variable

For Constants and Read-Only variables there value once assigned cannot be changed. Then what is the difference between them..? Let me explain by a example: Example: class DiffConstant { const int x = 1; // Write the remaining code } when this class is compiled all the places where 'x' is there it will be replaced by '1'. The value for the constant has to be given at the time of declaration itself. In the case of Read only data, we can set the value in the constructor. Example: public class DiffReadOnly { private readonly int x; public DiffReadOnly(int y) { x= y; } } *************** DiffReadOnly a = new DiffReadOnly(5); DiffReadOnly b = new DiffReadOnly(6); DiffConstant c = new DiffConstant(7); DiffConstant d = new DiffConstant(8); *************** In this case, at the time object creation, we can set the value for the 'x'. Here the value of 'x' in the object a is 5 and the value of 'x' in object b is 6. And the value of x in both objects c a...