Manage ASP.NET Providers by cglessner 23 months ago
View followups from cglessner and cglessner | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1668"></script>download | new post
Manage ASP.NET MemberShip, Role and Profile Provider with PowerShell. Especially useful with SqlMembershipProvider. I use it to manage SharePoint users with form based authentication (FBA).
- # Manage_ASP_NET_Providers.ps1
- # by Chistian Glessner
- # http://iLoveSharePoint.com
- [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web") # posh 2.0: Add-Type -Assembly "System.Web"
- function global:Set-AppConfigPath($path=$(throw "-path is mandatory"))
- {
- [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $path )
- }
- function global:Get-MembershipProvider($appConfigPath=$null, $providerName=$null)
- {
- if($appConfigPath -ne $null)
- {
- Set-WebConfigPath $webConfigPath
- }
- if($providerName -eq $null)
- {
- return [System.Web.Security.Membership]::Provider
- }
- else
- {
- return [System.Web.Security.Membership]::Providers[$providerName]
- }
- }
- function global:Get-RoleProvider($appConfigPath=$null, $providerName=$null)
- {
- if($appConfigPath -ne $null)
- {
- Set-WebConfigPath $webConfigPath
- }
- if($providerName -eq $null)
- {
- return [System.Web.Security.Roles]::Provider
- }
- else
- {
- return [System.Web.Security.Roles]::Providers[$providerName]
- }
- }
- function global:Get-ProfileProvider($appConfigPath=$null, $providerName=$null)
- {
- if($appConfigPath -ne $null)
- {
- Set-WebConfigPath $webConfigPath
- }
- if($providerName -eq $null)
- {
- return [System.Web.Profile.ProfileManager]::Provider
- }
- else
- {
- return [System.Web.Profile.ProfileManager]::Providers[$providerName]
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository