The following code shows how to retrieve “Metadata” for all entities in an organization by sending “RetrieveAllEntitiesRequest” by the Organization Service.
RetrieveAllEntitiesRequest req = new RetrieveAllEntitiesRequest();
req.EntityFilters = EntityFilters.Privileges;
req.RetrieveAsIfPublished = true;
RetrieveAllEntitiesResponse resp = (RetrieveAllEntitiesResponse)_serviceproxy.Execute(req);
Note: You can find how to create service proxy at the following link https://crmprof.wordpress.com/2013/03/13/creating-organization-service-proxy-in-microsoft-dynamics-crm-2011/