Hi Prachi,
Sharing access granted by Force.com through record ownership, the role hierarchy, territory hierarchy, teams, and sharing rules:
Record Ownership: Each record is owned by a user. The record owner is automatically granted Full Access, allowing them to view, edit, transfer, share, and delete the record. Role Hierarchy: The role hierarchy enables users above another user in the hierarchy to have the same level of access to records owned by or shared with users below them. Territory Hierarchy: Salesforce Territory Management provides a way to grant access to accounts based on characteristics of those accounts. The territory hierarchy enables users to view data shared to their territories or territories below them in the hierarchy.
Teams: Account Teams, Sales Teams and Case Teams provide access to a group of users who work on a particular account, opportunity or case.
Sharing Rules: Sharing rules are defined by administrators. They automatically grant users within a given group/role access to records owned by a specific group of users. Criteria based sharing rules automatically grant a users within a given group/role access to records based on field values within those records. User Managed Sharing, also known as Manual Sharing User managed sharing allows the record owner, or any user with Full Access to a record, to share the record with another user/group of users. This is generally done by an end-user, for a single record. User managed sharing is removed when the record owner changes or when the access granted in the sharing does not grant additional access beyond the object's organization-wide sharing default access level.
Apex Managed Sharing
Apex managed sharing is a type of "Programatic Sharing" which allows you to define a custom sharing reason to associate with your programatic share. Standard Salesforce objects support "Programatic Sharing" while custom objects support Apex managed sharing. More specifically, object shares can be written to both standard and custom objects, however custom sharing reasons can only be defined for shares written to custom objects.
Apex managed sharing provides developers with the ability to support an application’s particular sharing requirements programmatically via Apex code.
The sample use case for Apex managed sharing that we will explore in this article is an "after insert" trigger that grants 'edit' access on a private record to a user specified in a lookup field on that record.
Another example use case would be a trigger that shares a record with a group of users once the record meets certain criteria - you could automatically grant 'read' access on a record to a team once the record reaches a certain stage or currency amount. You're not limited to writing triggers though-you can also use Apex managed sharing in custom Visualforce controllers for example. Now let's dive in and learn how records are shared on the platform.
Hope this helps.