July 11, 2013

Orphan Event Receiver

I was wokring on to remove 'Orphan Event Receiver' without affecting the exitsting application, I research a lot and found one workaround,



Steps to Remove orphan event receiver,

1)      Use SharePoint Manager Utility, to check is there any event receiver present or not, if present remove the event receiver using SharePoint Manager Utility
2)      Execute following power shell script,
  function Remove-SPFeatureFromContentDB($ContentDb, $FeatureId, [switch]$ReportOnly)
{
    $db = Get-SPDatabase | where { $_.Name -eq $ContentDb }
    [bool]$report = $false
    if ($ReportOnly) { $report = $true }
   
    $db.Sites | ForEach-Object {
       
        Remove-SPFeature -obj $_ -objName "site collection" -featId $FeatureId -report $report
               
        $_ | Get-SPWeb -Limit all | ForEach-Object {
           
            Remove-SPFeature -obj $_ -objName "site" -featId $FeatureId -report $report
        }
    }
}
function Remove-SPFeature($obj, $objName, $featId, [bool]$report)
{
    $feature = $obj.Features[$featId]   
    if ($feature -ne $null) {
        if ($report) {
            write-host "Feature found in" $objName ":" $obj.Url -foregroundcolor Red
        }
        else
        {
            try {
                $obj.Features.Remove($feature.DefinitionId, $true)
                write-host "Feature successfully removed from" $objName ":" $obj.Url -foregroundcolor Red
            }
            catch {
                write-host "There has been an error trying to remove the feature:" $_
            }
        }
    }
    else {
        #write-host "Feature ID specified does not exist in" $objName ":" $obj.Url
    }
}
Remove-SPFeatureFromContentDB -ContentDB "ContentDBName" -FeatureId "FeatureID" –ReportOnly
This Command will report the Feature is present in DB or not.
 
Remove-SPFeatureFromContentDB-ContentDB "ContentDBName"-FeatureId "FeatureID"
This command will remove the Feature from DB

After that check the featuer still existing using 'SharePoint Manager' and if still exisit delete using 'SharePoint Manager'
And reinstall the fearture...
Thanks... if you found any better solution please post.

July 4, 2013

Allow Anonymous users but still SharePoint site popup for Credentials.

With some development part, I came across one issue, I allow Anonymous users on my site, but when I access Portal, still it gives popup for credentials..

I searched all blogs, and check setting everywhere, but unable to find the issue, then last I come across one article in TechNet (Choose security groups) and that help me to resolve the issue.

If in permission for Site in Central Admin, has Deny All; then portal will not behave as Anonymous. So I removed the Deny All permissions and it works..

Here is the article.. (Link)
 
Permission policies provide a centralized way to configure and manage a set of permissions that applies to only a subset of users or groups in a Web application. You can manage permission policy for anonymous users by enabling or disabling anonymous access for a Web application. If you enable anonymous access for a Web application, site administrators can then grant or deny anonymous access at the site collection, site, or item level. If anonymous access is disabled for a Web application, no sites within that Web application can be accessed by anonymous users.
  • None No policy. This is the default option. No additional permission restrictions or additions are applied to site anonymous users.
  • Deny Write Anonymous users cannot write content, even if the site administrator specifically attempts to grant the anonymous user account that permission.
  • Deny All Anonymous users cannot have any access, even if site administrators specifically attempt to grant the anonymous user account access to their sites.
Hope it will help...