Commit f8aef773 authored by Laurent Sittler's avatar Laurent Sittler ©
Browse files

Copy sources from CodePlex

parent 85739ad1

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Key", "Key", "{AFD65F9F-D093-4124-8865-83E21DD3434F}"
ProjectSection(SolutionItems) = preProject
OrbitOne.SharePoint.Claims.SignIn\OrbitOne.SharePoint.snk = OrbitOne.SharePoint.Claims.SignIn\OrbitOne.SharePoint.snk
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrbitOne.SharePoint.Claims.SignIn", "OrbitOne.SharePoint.Claims.SignIn\OrbitOne.SharePoint.Claims.SignIn.csproj", "{67570694-8303-4B14-A413-C77E89A3DC9C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67570694-8303-4B14-A413-C77E89A3DC9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67570694-8303-4B14-A413-C77E89A3DC9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67570694-8303-4B14-A413-C77E89A3DC9C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{67570694-8303-4B14-A413-C77E89A3DC9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67570694-8303-4B14-A413-C77E89A3DC9C}.Release|Any CPU.Build.0 = Release|Any CPU
{67570694-8303-4B14-A413-C77E89A3DC9C}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System;
using System.Text.RegularExpressions;
using System.Web.UI;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;
namespace OrbitOne.SharePoint.Claims.SignIn
{
public class AutoSignin : Page
{
protected override void OnLoad(EventArgs e)
{
if (SPContext.Current == null) return;
if (SPContext.Current.Site == null) return;
if (SPContext.Current.Site.WebApplication == null) return;
SPWebApplication app = SPContext.Current.Site.WebApplication;
SignInConfiguration config = app.GetChild<SignInConfiguration>("SignInConfig");
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
SPIisSettings settings = app.IisSettings[zone];
string ip = IpNetworking.GetIP4Address();
ip = Regex.Replace(ip, @"^(?<Prefix>(\d{1,3}\.){3})\d{1,3}$", "${Prefix}*");
var signinPageMappings = config.SingInPageMappings;
if (config != null && config.ProviderMappings.ContainsKey(ip))
{
string targetProvider = config.ProviderMappings[ip];
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
if (string.Compare(provider.DisplayName, targetProvider, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
|| string.Compare(provider.ClaimProviderName, targetProvider, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
{
string url = provider.AuthenticationRedirectionUrl.ToString();
if(signinPageMappings.ContainsKey(provider.DisplayName))
{
url = signinPageMappings[provider.DisplayName];
}
if (provider is SPWindowsAuthenticationProvider)
{
components = EnsureReturnUrl(components);
}
SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
}
}
}
else
{
string loginPage = "/_forms/default.aspx";
if(signinPageMappings.ContainsKey("default"))
{
loginPage = signinPageMappings["default"];
}
SPUtility.Redirect(loginPage, SPRedirectFlags.Default, this.Context, components);
Response.Write("No authentication provider is mapped to your request address, or no matching authentication provider could be found.");
}
base.OnLoad(e);
}
private string EnsureReturnUrl(string queryString)
{
if(string.IsNullOrEmpty(queryString))
{
queryString = "?";
}
if (!queryString.Contains("ReturnUrl="))
{
if (!string.IsNullOrEmpty(queryString))
{
queryString = queryString + "&";
}
queryString = queryString + "ReturnUrl=/";
}
return queryString;
}
}
}
\ No newline at end of file
using System.ComponentModel;
using System.Management.Automation;
namespace OrbitOne.SharePoint.Claims.SignIn
{
[RunInstaller(true)]
public class CmdletInstaller
: PSSnapIn
{
public CmdletInstaller()
: base()
{ }
public override string Name
{
get { return "ClaimsSignInAdmin"; }
}
public override string Vendor
{
get { return "Sample Originally by Bryan Porter, enhanced by Orbit One"; }
}
public override string Description
{
get { return "This is a PowerShell snap-in that adds cmdlets to administer the auto-signin sample."; }
}
}
}
using System;
using System.Net;
using System.Web;
namespace OrbitOne.SharePoint.Claims.SignIn
{
public class IpNetworking
{
public static string GetIP4Address()
{
string IP4Address = String.Empty;
foreach (IPAddress ipa in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
{
if (ipa.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = ipa.ToString();
break;
}
}
if (IP4Address != String.Empty)
{
return IP4Address;
}
foreach (IPAddress ipa in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (ipa.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = ipa.ToString();
break;
}
}
return IP4Address;
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ProjectItem Type="Microsoft.VisualStudio.SharePoint.MappedFolder" SupportedTrustLevels="FullTrust" SupportedDeploymentScopes="Package" xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
<ProjectItemFolder Target="IDENTITYMODEL\LOGIN" Type="TemplateFile" />
</ProjectItem>
\ No newline at end of file
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Page Language="C#" AutoEventWireup="true" Inherits="OrbitOne.SharePoint.Claims.SignIn.AutoSignin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{67570694-8303-4B14-A413-C77E89A3DC9C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OrbitOne.SharePoint.Claims.SignIn</RootNamespace>
<AssemblyName>OrbitOne.SharePoint.Claims.SignIn</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BB1F664B-9266-4fd6-B973-E1E44974B511};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SandboxedSolution>False</SandboxedSolution>
<PostDeploymentCommand>C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\installutil /assemblyname "OrbitOne.SharePoint.Claims.SignIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c7a593397c60142" /u
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\installutil /assemblyname "OrbitOne.SharePoint.Claims.SignIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c7a593397c60142"</PostDeploymentCommand>
<PreDeploymentCommand>
</PreDeploymentCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>OrbitOne.SharePoint.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.IdentityModel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SharePoint.Powershell, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Powershell.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.SharePoint" />
<Reference Include="Microsoft.SharePoint.Security" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoSignin.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="IpNetworking.cs" />
<Compile Include="CmdletInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SignInConfiguration.cs" />
<Compile Include="SPCmdletGetSignInConfigObject.cs" />
</ItemGroup>
<ItemGroup>
<None Include="LOGIN\SharePointProjectItem.spdata">
<SharePointProjectItemId>{640af85c-85e9-4fbe-bd6a-ed5b4985aeb1}</SharePointProjectItemId>
</None>
<None Include="OrbitOne.SharePoint.snk" />
<None Include="Package\Package.package">
<PackageId>{75418cbb-a824-4230-859f-8fcbd0fc77ac}</PackageId>
</None>
<None Include="Package\Package.Template.xml">
<DependentUpon>Package.package</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Features\" />
</ItemGroup>
<ItemGroup>
<Content Include="LOGIN\autosignin.aspx">
<SubType>ASPXCodeBehind</SubType>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="8F2CDF22-F28F-4404-90C5-CD824BD790C5" xmlns="http://schemas.microsoft.com/sharepoint/">
</Solution>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="75418cbb-a824-4230-859f-8fcbd0fc77ac" solutionId="75418cbb-a824-4230-859f-8fcbd0fc77ac" resetWebServer="false" name="OrbitOne.SharePoint.Claims.SignIn" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/PackageModel">
<projectItems>
<projectItemReference itemId="640af85c-85e9-4fbe-bd6a-ed5b4985aeb1" />
</projectItems>
</package>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OrbitOne.SharePoint.Claims.SignIn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Orbit One")]
[assembly: AssemblyProduct("OrbitOne.SharePoint.Claims.SignIn")]
[assembly: AssemblyCopyright("Copyright © Orbit One 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("67570694-8303-4b14-a413-c77e89a3dc9c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System.Management.Automation;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.PowerShell;
namespace OrbitOne.SharePoint.Claims.SignIn
{
[Cmdlet("Get", "SPSignInConfiguration", DefaultParameterSetName = "DefaultSet")]
public class SPCmdletGetSignInConfigObject
: SPCmdlet
{
private SPWebApplicationPipeBind m_webAppPipeBind;
protected override void InternalProcessRecord()
{
SPWebApplication webApp = m_webAppPipeBind.Read();
SignInConfiguration sc = webApp.GetChild<SignInConfiguration>("SignInConfig");
if (sc == null)
{
sc = new SignInConfiguration("SignInConfig", webApp);
}
sc.Update();
base.WriteObject(sc);
}
[ValidateNotNull]
[Parameter(Mandatory=true, ValueFromPipeline=true, Position=0)]
[Alias(new string[] { "WebApplication", "WebApp"})]
public SPWebApplicationPipeBind Identity
{
get { return m_webAppPipeBind; }
set { m_webAppPipeBind = value; }
}
}
}
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace OrbitOne.SharePoint.Claims.SignIn
{
/// <summary>
/// Holds configuration data for our auto-sign in login page.
/// </summary>
/// <remarks>
/// When an IP address is associated with a specific authentication provider, and that configuration stored with the SPWebApplication instance,
/// the custom autosignin.aspx page will automatically direct users from matching source addresses to the appropriate authentication provider page.
/// </remarks>
[Guid("4C28E13B-FDE1-448B-BEEC-31224A98BA2C")]
public class SignInConfiguration
: SPPersistedObject
{
[Persisted()]
private Dictionary<string, string> m_providerMappings = new Dictionary<string, string>();
[Persisted()]
private Dictionary<string, string> m_signinPageMappings = new Dictionary<string, string>();
public SignInConfiguration()
: base()
{ }
public SignInConfiguration(string name, SPPersistedObject parent)
: base(name, parent)
{ }
public SignInConfiguration(string name, SPPersistedObject parent, Guid id)
: base(name, parent, id)
{ }
public static Guid ObjectId
{
get { return new Guid("4C28E13B-FDE1-448B-BEEC-31224A98BA2C"); }
}
public void AddProviderMapping(string sourceAddress, string authProviderName)
{
if (m_providerMappings.ContainsKey(sourceAddress))
{
m_providerMappings[sourceAddress] = authProviderName;
}
else
{
m_providerMappings.Add(sourceAddress, authProviderName);
}
}
public void RemoveProviderMapping(string sourceAddress, string authProviderName)
{
if (m_providerMappings.ContainsKey(sourceAddress))
{
m_providerMappings.Remove(sourceAddress);
}
}
public void Clear()
{
m_providerMappings.Clear();
}
public Dictionary<string, string> ProviderMappings
{
get { return m_providerMappings; }
}
public Dictionary<string, string> SingInPageMappings
{
get { return m_signinPageMappings; }
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment