Tuesday, 16 April 2013

Get all the users in the groups

// Get all the users in the groupsSPSite site = new SPSite("http://spsportal:8181");

SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates =
true;
try{
foreach (SPGroup group in web.SiteGroups){
Response.Write(
"<b> " + group.Name + "</b> <br>");
foreach (SPUser user in group.Users){
Response.Write(
"-" + user.Name + "<br>");}
}
}

catch (Exception ex){
Response.Write(ex.Message);
}

Create a group with role permissions

//Create a group and Role permissionsSPSite site = new SPSite("http://Madan:8181");

SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates =
true;
try{
SPMember siteOwner = web.SiteAdministrators[0];
//Assign the group name string grpName = "MVMMohanGroup";
//check if group exists bool grpExists = false;
foreach (SPGroup group in web.SiteGroups)
if (group.Name.ToLower() == grpName.ToLower())grpExists =
true;
if (!grpExists){
web.SiteGroups.Add(grpName, siteOwner,
null, "Eve Custom Group that I created because I have the permissions!");web.Update();

//get a reference to the group we just createdSPGroup customGroup = web.SiteGroups[grpName];
//add the group to the quicklaunchweb.Properties["vti_associategroups"] = web.Properties["vti_associategroups"] + ";" + customGroup.ID.ToString();
//Assign the roles for itSPGroup Role2Group = web.SiteGroups[grpName];
//Get the designer role definition to assign to our custom group any custom role alsoSPRoleDefinition mydesignerRoleDefinition = web.RoleDefinitions["View Only"];
//assign designer role to our custom group at the web levelSPRoleAssignment roleAssignment = new SPRoleAssignment(Role2Group);roleAssignment.RoleDefinitionBindings.Add(mydesignerRoleDefinition);
web.RoleAssignments.Add(roleAssignment);
customGroup.Update();
web.Properties.Update();
Response.Write(
"Group is created.");}

else{
Response.Write(
"Group is already created.");}
}

catch (Exception ex){
Response.Write(
"Group is not created." + ex.Message);}

Wednesday, 16 January 2013

http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas

Error occurred in deployment step ‘Install App for SharePoint’: App Management Shared Service Proxy is not installed.

While deploying getting this error..
“App Management Shared Service Proxy is not installed”
To resolve this..
- Go to Central Admin > Application Management > Manage service applications.. make sure that the following services are running..
  • App Management Service
  • Secure Store Service
  • Security Token Service Application

Error occurred in deployment step ‘Install App for SharePoint’: Failed to install App for SharePoint.

Once you have the necessary services started, Follow the steps provided in the “Configure an isolated app domain to create and deploy SharePoint-hosted apps” section of this article.. How to: Set up an on-premises development environment for apps for SharePoint

For step#2: Set-SPAppDomain “your app domain” .. I used: Set-SPAppDomain “apps.sp2013domain.com”

So when I set the IE proxy “Add your isolated app domain to your bypass list in Internet Explorer”, here is the settings that worked for me



For step#7: if you get the error
“Set-SPAppSiteSubscriptionName : The requested service, ‘http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas’ could not be activated. See the server’s diagnostic trace logs for more information.”

just do an iisreset or free up some RAM memory. This service needs at least 5% of the total RAM for its purpose.

BDC


public static Dictionary<Int32, Customer> d = null; public static Customer ReadItem(Int32 id) { // take a copy for SharePoint
Customer c = new Customer();
Customer e = d[id];
c.CustomerId = e.CustomerId;
c.FirstName = e.FirstName;
c.LastName = e.LastName;
c.Message = e.Message;
return c;
}
public static IEnumerable<Customer> ReadList()
{
// this is usually the first method called so check for null
if (d == null)
{
d = new Dictionary<Int32, Customer>();
for (int i = 0; i < 10; i++)
{
Customer e = new Customer();
e.CustomerId = i;
e.Message = i + " Item Data";
e.FirstName = i + " First Name";
e.LastName = i + " Last Name";
d.Add(i, e);
}
}
return d.Values;
}
public static void Update(Customer customer, Int32 id)
{
d[id].FirstName = customer.FirstName;
d[id].LastName = customer.LastName;
d[id].Message = customer.Message;
}

Tuesday, 1 January 2013

Windows Authentication Mode= error

<configuration>
 <system.web>
  <compilation debug="true">
   <assemblies>
    <add assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="Microsoft.SharePoint.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
    <add assembly="Microsoft.SharePoint.Client.Runtime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/></assemblies></compilation></system.web>
 <system.webServer>
  <security>
   <authorization>
    <add accessType="Deny" users="?"/>
   </authorization>
  </security>
 </system.webServer>
</configuration>