Wednesday, 30 March 2011

Difference between cross join and Full outer join

Cross Join: No join conditions are specified.
Results in pairs of rows.
Results in Cartesian product of two tables

. 
Full Outer Join:
A combination of both left and right outer joins.
Results in every row from both of the tables , at least once.
Assigns NULL for unmatched fields.

Tuesday, 29 March 2011

SQL Server Profiler

SQL Server Profiler SQL Server Profiler is a graphical tool that helps in the monitoring of an instance of SQL Server Database Engine or Analysis Services. The data about each event can be captured to a file or table for analysis at a later date. SQL Server 2005 incorporates certain new features into the SQL Server Profiler.

The significant enhancements are as under:
1. Rollover trace files.
2. New extensibility standard.
3. Profiling of Microsoft SQL Server 2005 Analysis Services (SSAS).
4. Profiling of Microsoft SQL Server 2005 Integration Services (SSIS).
5. Saving of traced Showplan as XML.
6. Save trace results as XML.
7. Aggregate view.
8. Correlation of Trace Events to Performance Monitor Counters.
Before examining the process of using SQL Server Profiler, let us look at the terminology associated with the tool.

1. An Event is an action that is generated within an instance of a SQL Server Database Engine. These could be login failures, connection failures or disconnections. It would include events such as T-SQL statements, remote procedure call batch status, the start or end of a stored procedure, the start or end of statements within a stored procedure and so on.. These are displayed in the trace in a single row intersected by data columns with descriptive details.

2. An Event Class is an event that can be traced and contains all of the data that can be reported by the event. SQL: Batch completed for instance is an event class, just as .Audit Login, .Audit Logout etc are event classes.

3. An Event Category defines the methodology used for grouping events within the SQL Server Profiler. For instance lock events will be categorized under Lock event category.

4. A Data Column is an attribute of an event class that is captured in the trace. The event class determines the type of data that can be collected and not all data columns are applicable to all event classes.

5. A Template is the default configuration for a trace. It includes the event classes that are required for monitoring with the SQL Server Profiler.

6. A Trace captures data based on selected event classes, data columns and filters. For instance a trace monitor can be created to capture Exception event class with the Error, State and Severity data columns.

7. Data can be Filtered by specifying criteria of selection during the execution of an event. This feature is used to reduce the size of the Trace.

The SQL Server Profiler tool captures the events and stores them in a trace file for analysis. The trace file enables the replay of the events for the diagnosis of the problems. The SQL Server Profiler is used for stepping through the problem to find the cause or finding and diagnosing slow running queries, or capturing T-SQL statements that lead to a problem or Monitoring the performance of the SQL Server for tuning workloads.
Auditing actions are also supported by the Profiler. Audit traces help in maintaining the security of the server.
The rich interface of the Profiler helps the administrator create and manage traces and analyze and replay trace outputs. In the production environment the DBA will have to create a focused and well organized series of traces.

He may want to do the following actions:
1. Monitor the performance of an instance of the SQL Server Database Engine, Analysis Server or Integration Services.
2. Debug Transact SQL statements and stored procedures
3. Identify slowly executing procedures and queries.
4. Perform stress testing and quality assurance by replaying traces
5. Replay traces of one or more users
6. Perform query analysis.
7. Test T-SQL statements and stored procedures in the development phase
8. Troubleshoot problems
9. Audit and review activity
10. Provide standardized hierarchical structure to trace results by saving them to the XML file.
11. Aggregate trace results
12. Correlate performance counters
13. Configure trace problems.
14. Allow non administrators create traces.

The SQL Server Profiler can be accessed in several ways. It can be invoked from the Start Menu, from the tools menu in the SQL Server Management Studio and from the Tools menu in the Database Engine Tuning Advisor.
To start SQL Server Profiler from the Start menu
On the Start menu, point to All Programs, point to Microsoft SQL Server 2005, point to Performance Tools, and then click SQL Server Profiler.

SQL Server Profiler can correlate Performance Monitor Counters with SQL Server or SSAS events. Administrators can select from a predefined set of Performance Monitor Counters and save them at specified time intervals while also collecting a SQL Server or SSAS trace. Users can choose an aggregate option and select a key for aggregation. This will enable users to see a view that shows the column on which the aggregation was performed, along with a count for the number of rows that make up the aggregate value. Trace results can be saved in an XML format in addition to the standard save formats of ANSI, UNICODE, and OEM. Results saved in this fashion can be edited and used as input for the Replay capability of SQL Server Profiler. Showplan results can be saved in an XML format, which can be later loaded for graphical Showplan display in Query Editor without the need to have an underlying database. SQL Server Profiler will also display a graphical representation of Showplan XML events at that the time they are captured by SQL Server Profiler. SQL Server Profiler can now display events raised by SSIS. SQL Server Profiler now supports capturing and displaying events raised by SSAS. SQL Server Profiler uses an XML-based definition that allows SQL Server Profiler to more easily capture events from other types of servers and programming interfaces. SQL Server Profiler can replay one or more collected rollover trace files continuously and in order.

Monday, 28 March 2011

ASP.NET Authorization


Authorization determines whether an identity should be granted access to a specific resource
The following shows the syntax for the authorization section:
This section of the web.config determines the users who will be authorized to or denied from the website

<authorization>
<[allow|deny] users roles verbs />
</authorization>


Attribute

Description
users Identifies the targeted identities (user accounts) for this element.
Anonymous users are identified using a question mark (?). You can specify all authenticated users using an asterisk (*).
roles Identifies a role for the current request that is allowed or denied access to the resource.
verbs Defines the HTTP verbs to which the action applies, such as GET, HEAD, and POST. The default is "*", which specifies all verbs.


For Example:
The default value <deny users="?" /> means to deny any anonymous (unauthenticated) user trying to access the website
<deny users="john, smith, Ahmed /><deny users="*" /> <allow users="john, smith, Ahmed />

ASP.NET provides the concept of roles that gives each role a different view on specific pages.

<location path="HRpages">
<system.web>
<authorization>
<allow roles="HR" />
<deny users="*" />
</authorization>
</system.web>
</location>
location here means the folder name which holds the .aspx for some specific role.
As the example shows, <location path="HRpages"> means that all .aspx files under the HRpages folder are protected. <allow roles="HR" /><deny users="*" /> mean deny every one from accessing pages under HRpages except those having the HR role.


The following authorization section shows how to allow access to the John identity and deny access to all other users:<authorization>
<allow users="John"/>
<deny users="*"/>
</authorization>

The following example allows all users to perform an HTTP GET for a resource, but allows only the Kim identity to perform a POST operation:<authorization>
<allow verbs="GET" users="*"/>
<allow verbs="POST" users="Kim"/>
<deny verbs="POST" users="*"/>
</authorization>

which means, deny all users except john, smith, and Ahmed. means to deny the users: john, smith and Ahmed from accessing this website

Thursday, 24 March 2011

Authentication providers

The ASP.net architecture includes the concept of and authentication provider a piece of code whose job is to verify credentials and decide whether a particular request should be considered authenticated.
Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:
1.Windows Authentication
It  provider lets you authenticates users based on their windows accounts. This provider uses IIS to perform the authentication and then passes the authenticated identity to your code. This is the default provided for ASP.net.

<authentication mode="Windows">
<forms name=" AuthenticationDemo"  loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication>
3.Passport authentication


2. Forms authentication

 It provider uses custom HTML forms to collect authentication information and lets you use your own logic to authenticate users. The user's credentials are stored in a cookie for use during the session.

<authentication mode="forms">
<forms name=" AuthenticationDemo" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication>


3.Passport Authentication

It provider authenticates users  on Microsoft's passport service to authenticate users of your application

</authentication mode="passport">
<forms name=" AuthenticationDemo" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication
>

Different authentication Methods in asp.net

The ASP.net architecture includes the concept of and authentication provider a piece of code whose job is to verify credentials and decide whether a particular request should be considered authenticated.
Selecting an authentication provider is as simple as making an entry in the web.config file for the application. You can use one of these entries to select the corresponding built in authentication provider:
1.Windows Authentication
It  provider lets you authenticates users based on their windows accounts. This provider uses IIS to perform the authentication and then passes the authenticated identity to your code. This is the default provided for ASP.net.

<authentication mode="Windows">
<forms name=" AuthenticationDemo"  loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication>
3.Passport authentication

2. Forms authentication
 It provider uses custom HTML forms to collect authentication information and lets you use your own logic to authenticate users. The user's credentials are stored in a cookie for use during the session.

<authentication mode="forms">
<forms name=" AuthenticationDemo" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication>


3.Passport Authentication
It provider authenticates users  on Microsoft's passport service to authenticate users of your application

</authentication mode="passport">
<forms name=" AuthenticationDemo" loginUrl="logon.aspx" protection="All" path="/" timeout="30" />
</authentication
>

Difference between Http Get and Post

GET
1.The Get is one the simplest Http method.
2.get method is for getting something from the server
3.Its not secured as it is visible in plain text format
Post:
1The Post method is more powerful request.
2.By using Post we can request as well as send some data to the server.
3.Post Method is secured because Name-Value pairs cannot be seen in location bar of the web browser.

application pooling

1.An Application Pool can contain one or more applications and allows us
to configure a level of isolation between different Web applications.

2.Application pools used to isolate our web application for better security,
reliability, and availability and performance and keep running with out impacting each other .

Main Point to Remember:
1. Isolation of Different Web Application
2. Individual worker process for different web application
3. More reliably web application
4. Better Performance