Friday, December 24, 2010
Wednesday, December 22, 2010
Saturday, December 11, 2010
Add and Delete Sharepoint user with group name programmable.
private void AddUserToAGroup(string userLoginName, string userGroupName,int action)
{
//Executes this method with Full Control rights even if the user does not otherwise have Full Control
SPSecurity.RunWithElevatedPrivileges(delegate
{
//Don't use context to create the spSite object since it won't create the object with elevated privileges but with the privileges of the user who execute the this code, which may casues an exception
using (SPSite spSite = new SPSite(Page.Request.Url.ToString()))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
try
{
//Allow updating of some sharepoint lists, (here spUsers, spGroups etc...)
spWeb.AllowUnsafeUpdates = true;
SPUser spUser = spWeb.EnsureUser(userLoginName);
if (spUser != null)
{
SPGroup spGroup = spWeb.Groups[userGroupName];
if (spGroup != null)
{
if (action.ToString() == "0")
{
spGroup.AddUser(spUser);
}
else if (action.ToString() == "1")
{
spGroup.RemoveUser(spUser);
}
}
}
}
catch (Exception ex)
{
//Error handling logic should go here
}
finally
{
spWeb.AllowUnsafeUpdates = false;
}
}
}
});
}
protected void Button1_Click(object sender, EventArgs e)
{
AddUserToAGroup("ayyappan", "Designers",1);
}
protected void Button2_Click(object sender, EventArgs e)
{
AddUserToAGroup("ayyappan", "Designers",2);
}
{
//Executes this method with Full Control rights even if the user does not otherwise have Full Control
SPSecurity.RunWithElevatedPrivileges(delegate
{
//Don't use context to create the spSite object since it won't create the object with elevated privileges but with the privileges of the user who execute the this code, which may casues an exception
using (SPSite spSite = new SPSite(Page.Request.Url.ToString()))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
try
{
//Allow updating of some sharepoint lists, (here spUsers, spGroups etc...)
spWeb.AllowUnsafeUpdates = true;
SPUser spUser = spWeb.EnsureUser(userLoginName);
if (spUser != null)
{
SPGroup spGroup = spWeb.Groups[userGroupName];
if (spGroup != null)
{
if (action.ToString() == "0")
{
spGroup.AddUser(spUser);
}
else if (action.ToString() == "1")
{
spGroup.RemoveUser(spUser);
}
}
}
}
catch (Exception ex)
{
//Error handling logic should go here
}
finally
{
spWeb.AllowUnsafeUpdates = false;
}
}
}
});
}
protected void Button1_Click(object sender, EventArgs e)
{
AddUserToAGroup("ayyappan", "Designers",1);
}
protected void Button2_Click(object sender, EventArgs e)
{
AddUserToAGroup("ayyappan", "Designers",2);
}
Tuesday, November 30, 2010
Some examples how can use SPquery or caml query in SharePoint 2010 Client Object model.
Some examples how can use SPquery or caml query in SharePoint 2010 Client Object model.
var site;
var context;
var list;
var collListItem;
var context;
var list;
var collListItem;
context = new SP.ClientContext.get_current();
site = context.get_web();
context.load(site);
site = context.get_web();
context.load(site);
list = site.get_lists().getByTitle(‘MyList’);
context.load(list);
context.load(list);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘ ‘);
collListItem = list.getItems(camlQuery);
context.load(collListItem);
camlQuery.set_viewXml(‘
collListItem = list.getItems(camlQuery);
context.load(collListItem);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQuerySucceeded(sender, args) {
alert(“Request succeeded. ” + args.Message + “\n” + args.StackTrace);
}
}
function onQueryFailed(sender, args) {
alert(“Request failed. ” + args.Message + “\n” + args.StackTrace);
}
Thursday, October 28, 2010
The following data source cannot be used because PerformancePoint Services is not configured correctly.
The following data source cannot be used because PerformancePoint Services is not configured correctly.
If you’re setting up a fresh installation of Performance Point Services 2010 , you might think that all has gone well only to see the above error in Dashboard Designer once you try to start creating scorecards and reports. This is actually quite common – it seems there are a few extra steps to do before you can start using PPS 2010.
1) Set up the Unattended Service Account.
Go to the Central Administration page ( on Sharepoint ). Under Application Management , click on Manage Service Applications. Then click on Performance Point Service Application , then Performance Point Service Application Settings. We need to configure the Unattended Execution Account. This is the account that PPS will use to connect to the data source ( unless you use Per User Identity , but thats another story ). If you’ve never seen this page before , there are some interesting options there. Once you set this up and hit Apply. It might be successful, or it might give you another error….
2) The Unattended Service Account cannot be set for the service application.
The Secure Store Service key might not have been generated or properly refreshed
after the service was provisioned.
The Secure Store Service key might not have been generated or properly refreshed
after the service was provisioned.
Now I’m not the expert in the Secure Store Service , but Performance Point uses this to store the password for the Unattended execution account. If you get this error, you need to check that a key has been generated for the Secure Store Service. Once again , go to the Central Administration page, and under Application Management , click on Manage Service Applications. Now click on Secure Store Service. Click on Generate New Key. Once that is done, you can go back to set the Unattended Execution Account on the other page , and Dashboard Designer should then work fine.
Subscribe to:
Posts (Atom)