Authorizing User with LinkedIn and Get User Profile

Before some day my sir gave me work of authorizing users with their LinkedIn profiles. So i did some RnDs and found this 2 best examples in C#.

  1. LinkedInOAuth.rar.zip
  2. LinkedInAuth.rar.zip

Note: Please Give OAuth Redirect URL while registering your domain with LinkedIn for Key and Secret.

And in this example you will get User Profile as XML so use this code to make this xml to table format.

Here Response is a XML String.

StringBuilder output = new StringBuilder();
using (XmlReader reader = XmlReader.Create(new StringReader(response)))
{
XmlWriterSettings ws = new XmlWriterSettings();
ws.Indent = true;
using (XmlWriter writer = XmlWriter.Create(output, ws))
{
DataTable dtable = new DataTable();
DataRow dRow = dtable.NewRow();
string strElement = “”;

int count = 0;
bool enter = true;

while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
writer.WriteStartElement(reader.Name);
if (count == 0)
{
DataColumn column = new DataColumn(reader.Name);
dtable.Columns.Add(column);
strElement = reader.Name;
count++;
}
foreach (DataColumn dc in dtable.Columns)
{
if (dc.ColumnName.Equals(reader.Name))
{
enter = false;
}
}
if (enter)
{
DataColumn column = new DataColumn(reader.Name);
dtable.Columns.Add(column);
strElement = reader.Name;
}
enter = true;
break;
case XmlNodeType.Text:
writer.WriteString(reader.Value);
dRow[strElement] = reader.Value;
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
writer.WriteProcessingInstruction(reader.Name, reader.Value);
break;
case XmlNodeType.Comment:
writer.WriteComment(reader.Value);
break;
case XmlNodeType.EndElement:
writer.WriteFullEndElement();
break;
}
}
dtable.Rows.Add(dRow);
GridView1.DataSource = dtable;
GridView1.DataBind();
}
}

Advertisements
By Amar Trivedi Posted in ASP.NET

Comparison of sandboxed and farm solutions

Aspect Farm Sandbox
Deployment process Add the solution, and then deploy it to the farm. Upload the solution to a site collection, and then activate it in the site collection.
Who can deploy Farm administrator. If the solution contains an assembly, only a site collection administrator can deploy it. If the solution does not contain an assembly, a user who has full control at the root of the site collection can deploy it.
Data access Unrestricted. The solution can only access content from the site collection in which it was deployed.
Process the solution runs in Unrestricted IIS worker process, or whichever process the solution is deployed into. Separate worker process that has restricted rights.
Code access security The solution developer can set the code access security policy when packaging the solution. Restricted. For more information, see Deploying a sandboxed solution (http://go.microsoft.com/fwlink/?LinkId=177369).
Monitoring Not monitored. Monitored, and limited by quotas set by the farm administrator.
Load balancing Varies, based on the kind of solution. Configurable separately from non-sandboxed solutions.
Solution functionality Unrestricted. Restricted, as described in What a sandboxed solution cannot contain.