Friday, April 20, 2012
Web Service permission issue for reader / viewer user in SharePoint
you may come across permission error while using list.asmx webservice in infopath. you may be able to use web service successfully for minimum contribute user but not for reader user. for this you need to grand permission for all authenticated users in default zone of that web application's user policy.
code to check logged in user exist in provided Active Directory (AD) group or not
using Microsoft.SharePoint.Utilities;
///
/// Method to check if logged in user exists in provided AD group or not.
///
/// AD group Name
///
public bool isMemberOfGroup(string strGroupName)
{
bool reachedMaxCount;
int limit = 100;
string strUserDispName = null;
bool returnValue = false;
if (SPContext.Current != null)
{
string strCurUserName = SPContext.Current.Web.CurrentUser.LoginName;
string URL = SPContext.Current.Site.Url;
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite mySite = new SPSite(URL))
{
using (SPWeb sPCurrentWeb = mySite.OpenWeb())
{
SPPrincipalInfo[] users = SPUtility.GetPrincipalsInGroup(sPCurrentWeb, strGroupName, limit, out reachedMaxCount);
if (users != null)
{
foreach (SPPrincipalInfo user in users)
{
strUserDispName = user.LoginName;
if (string.Equals(strCurUserName, strUserDispName, StringComparison.OrdinalIgnoreCase))
{
returnValue = true;
break;
}
}
}
}
}
});
}
return returnValue;
}
///
/// Method to check if logged in user exists in provided AD group or not.
///
/// AD group Name
///
public bool isMemberOfGroup(string strGroupName)
{
bool reachedMaxCount;
int limit = 100;
string strUserDispName = null;
bool returnValue = false;
if (SPContext.Current != null)
{
string strCurUserName = SPContext.Current.Web.CurrentUser.LoginName;
string URL = SPContext.Current.Site.Url;
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite mySite = new SPSite(URL))
{
using (SPWeb sPCurrentWeb = mySite.OpenWeb())
{
SPPrincipalInfo[] users = SPUtility.GetPrincipalsInGroup(sPCurrentWeb, strGroupName, limit, out reachedMaxCount);
if (users != null)
{
foreach (SPPrincipalInfo user in users)
{
strUserDispName = user.LoginName;
if (string.Equals(strCurUserName, strUserDispName, StringComparison.OrdinalIgnoreCase))
{
returnValue = true;
break;
}
}
}
}
}
});
}
return returnValue;
}
Reset or Clear Multi select list box values for reloading with new values
Think suppose, if you come across of requirement ‘clear/reset values of multi select or repeating group’ you don’t have direct way in InfoPath as we do for Set Field Value. Because, InfoPath won’t allow us to select Group in Set Field Value action.
Hence what you do is, create a text field with the name that you like for Multi Select List box say “StatesList” and then Create a group say name as “Empty Group”
Now, in go to set field value action and select “StatesList” in Field and select “EmptyGroup” in Value and then click ok to finalize the rule.
Now, delete “StateList” text field and create Multi Select List box with same name “StatesList”.
If infopath is not allowing you to select Group field in Value, do same technique of creating text field with group name and use it in rule and then delete it and recreate Group field.
Every thing works as expected even though you deleted the “StatesList” text field. Rule will still alive and work properly on newly created multi select list box.
Cheers..!
Raj
Hence what you do is, create a text field with the name that you like for Multi Select List box say “StatesList” and then Create a group say name as “Empty Group”
Now, in go to set field value action and select “StatesList” in Field and select “EmptyGroup” in Value and then click ok to finalize the rule.
Now, delete “StateList” text field and create Multi Select List box with same name “StatesList”.
If infopath is not allowing you to select Group field in Value, do same technique of creating text field with group name and use it in rule and then delete it and recreate Group field.
Every thing works as expected even though you deleted the “StatesList” text field. Rule will still alive and work properly on newly created multi select list box.
Cheers..!
Raj
How to Change New Icon time period in SharePoint
In this article I am describing about how to change the time period that a new Icon is displayed while you upload or add new item in SharePoint list.You may be also thought "How long an item does really stays new?". Usually many people ask these questions because they have uploaded/migrated a bunch of documents from their file share which are not really "new", but they get the !New tag assigned to them anyway.
This feature applies to not only Document Libraries, but also to other Lists such as Tasks, Issues, Contacts, and Links etc. In the default installation of SharePoint, the "New" tag gets appended to every new item in SharePoint lists and remains there for one calendar day. We have two options here, but make sure we have access to the SharePoint Server.
Increase the number of days that icon should appear
Eliminate the appearance of the icon altogether
We can use stsadm tool to accomplish this taskGo to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
The "setproperty" command will be used for this task as
stsadm -o setproperty -pn days-to-show-new-icon -pv 2
-pn = Property name
-pv = Property value
enjoy blogging....:)
This feature applies to not only Document Libraries, but also to other Lists such as Tasks, Issues, Contacts, and Links etc. In the default installation of SharePoint, the "New" tag gets appended to every new item in SharePoint lists and remains there for one calendar day. We have two options here, but make sure we have access to the SharePoint Server.
Increase the number of days that icon should appear
Eliminate the appearance of the icon altogether
We can use stsadm tool to accomplish this taskGo to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
The "setproperty" command will be used for this task as
stsadm -o setproperty -pn days-to-show-new-icon -pv 2
-pn = Property name
-pv = Property value
enjoy blogging....:)
Subscribe to:
Comments (Atom)