Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to set up a web application that can be accessed from three kind of authentication on the default zone:

  • anonymous
  • Windows
  • FBA (over a custom provider)

and two other zones without the windows authentication.

I have this script :

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction 0

$defaultZoneUrl = "http://adm.local.mydomain.int"
$intranetZoneUrl = "https://local.mydomain.int"
$internetZoneUrl = "http://a.local.mydomain.int"

$winAp = new-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos
$anoAp = new-SPAuthenticationProvider -AllowAnonymous
$fbaAp = new-SPAuthenticationProvider -ASPNETMembershipProvider "CustMembershipProvider" -ASPNETRoleProviderName "CustRoleProvider"



$webApp = new-SPWebApplication -ApplicationPool "SharePoint - 80" `
                               -AuthenticationProvider $winAp, $anoAp, $fbaAp `
                               -DatabaseName "Wss_Content_Dev" `
                               -HostHeader "adm.local.mydomain.int" `
                               -Name "Dev web application" `
                               -Port 80 `
                               -SignInRedirectURL "/_layouts/cust/login.aspx" 

$intranetWebApp = new-SPWebApplicationExtension -AuthenticationProvider $anoAp, $fbaAp `
                                                -Identity $webApp `
                                                -Zone "Intranet" `
                                                -HostHeader "local.mydomain.int" `
                                                -Port 443 `
                                                -SecureSocketsLayer `
                                                -SignInRedirectURL "/_layouts/cust/login.aspx" 

$anoWebApp = new-SPWebApplicationExtension -AuthenticationProvider $anoAp, $fbaAp `
                                           -Identity $webApp `
                                           -Zone "Intranet" `
                                           -HostHeader "a.local.mydomain.int" `
                                           -Port 80 `
                                           -SecureSocketsLayer `
                                           -SignInRedirectURL "/_layouts/cust/login.aspx" 

However, this breaks on the web application creation with the error :

New-SPWebApplication : Exception of type 'System.ArgumentException' was thrown.
Parameter name: provider
At E:\Scripts\SetupEnvironment\CreateWebAppAndZones.ps1:13 char:31
+ $webApp = new-SPWebApplication <<<<  -AllowAnonymousAccess `
    + CategoryInfo          : InvalidData: (Microsoft.Share...PWebApplication:SPCmdletNewSPWebApplication) [New-SPWebApplication], ArgumentException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPWebApplication

I also tried but setting explicitely the flag -AllowAnonymous but the error remains.

When I go to the Central administration, my Web app is created, but is not claims enabled.

How can I correct my script to reach my goal ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Answering myself...

I changed the script to perform these operations :

  1. Create the webapp with only Windows Auth
  2. Enable Claims authentication on the web app
  3. Add the remaining auth providers
  4. Extend the web app (passing all providers is working)

Here the updated script :

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction 0


$winAp = new-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos
$anoAp = new-SPAuthenticationProvider -AllowAnonymous
$fbaAp = new-SPAuthenticationProvider -ASPNETMembershipProvider "CustMembershipProvider" -ASPNETRoleProviderName "CustRoleProvider"



$webApp = new-SPWebApplication -ApplicationPool "SharePoint - 80" `
                               -AuthenticationProvider $winAp `
                               -DatabaseName "Wss_Content_Dev" `
                               -HostHeader "adm.local.mydomain.int" `
                               -Name "Dev web application" `
                               -Port 80 `
                               -SignInRedirectURL "/_layouts/cust/login.aspx" 

$webApp.UseClaimsAuthentication = $true
$webApp.Update()
$webApp.MigrateUsers($true)                               

Set-SPWebApplication -AuthenticationProvider $anoAp, $fbaAp -Identity $webApp -Zone "Default"   


$intranetWebApp = new-SPWebApplicationExtension -AuthenticationProvider $anoAp, $fbaAp `
                                                -Identity $webApp `
                                                -Zone "Intranet" `
                                                -HostHeader "local.mydomain.int" `
                                                -Port 443 `
                                                -SecureSocketsLayer `
                                                -SignInRedirectURL "/_layouts/cust/login.aspx" 

$anoWebApp = new-SPWebApplicationExtension -AuthenticationProvider $anoAp, $fbaAp `
                                           -Identity $webApp `
                                           -Zone "Intranet" `
                                           -HostHeader "a.local.mydomain.int" `
                                           -Port 80 `                                              
                                           -SignInRedirectURL "/_layouts/cust/login.aspx" 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.