Many of the operations you perform with the object model—even a simple listing—will require administrative permissions. This is because SharePoint applies security restrictions to the use of the object model. However, there are many times when you would like to display information—such as a site listing—to a user that does not have administrator rights. In these cases, you must utilize the SPSecurity class to temporarily run object model code with elevated permissions. These elevated permissions allow you to run code under the identity of the application pool account.
          In order to run code with elevated permissions, you must encapsulate the code in a function that has no return value. You then create an instance of the CodeToRunElevated class using the name of the function as an argument. You can subsequently execute the code by calling the RunWithElevatedPrivileges method of the SPSecurity object and passing in the CodeToRunElevated object. Below shown is  an example that calls a method to list all of the available features in a farm.

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"%>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<asp:Content ID="Content4" runat="server"
ContentPlaceHolderID="PlaceHolderMain">
<%
SPSecurity.CodeToRunElevated myCode =
new SPSecurity.CodeToRunElevated(ShowFeatures);
SPSecurity.RunWithElevatedPrivileges(myCode);
%>
</asp:Content>
<script language="C#" runat="server">
protected void ShowFeatures()
{
//Code goes here
}
</script>