Wednesday, December 28, 2011

SharePoint 2010 : “The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”



When you try to update or delete an List/Documentlibrary item you may get the following error

“The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”

This one was driving me nuts for a while as the error description is not very helpful (as usual). 
This is because the "user" doesn't have enough permissions.

One way to handle this is to temporarily allow unsafe update on the web before updating/deleting the List/Documentlibrary item (if you can't grant additional permissions to the "user")

See code below

web.AllowUnsafeUpdates = true;

item.Delete();

web.AllowUnsafeUpdates = false;


Note : If this helped you, please add a comment and share the link as it will motivate me to post more solutions like this.

Telerik Rad Upload Control : File Name issue with certain browsers


File Name issue with certain browsers.

Some browser instances wont work well with the property  "FileName" use "GetName()" method instead

<telerik:radupload>

Hope this save you some time to resolve a hard to reproduce bug with Telerik

See documentation

http://www.telerik.com/help/aspnet-ajax/upload-manipulating-files.html

Monday, December 26, 2011

Thursday, December 22, 2011

Windows 8 Development - Download

http://msdn.microsoft.com/en-us/windows/apps/br229516/

Wednesday, December 21, 2011

SharePoint 2010 - LDAP membership provider for FBA prefixes “i:0#.f|”


SharePoint 2010 - LDAP membership provider for FBA prefixes “i:0#.f|” .
if you are adding SharePoint user profile with code follow this format
"i:0#.f|lmymembershipprovider|myuserid"
mymembershipprovider : is the name of membership provider you defined in your web.config file
myuserid: "user id"
it is necessary to prefix the userid with membership provider if you defined multiple membership providers in your config file.
If you don't prefix "i:0#.f|" ('f' stands for Form Based Authentication) for an FBA user, Sharepoint won't identify the user when trying access userprofile store and may throw a security exception.
If you are yelling " WHY...???".......it's "SHAREPOINT" :)

Note : for windows authentication, the format is i:0#.w ('w' stands for windows)
Note : If this helped you, please add a comment and share the link as it will motivate me to post more solutions like this.

User Profile Synchronization between SharePoint 2010 and Domino Lotus


Sorry..... if you are looking for a configuration based solution. After much research I ended up writing a windows service using directory service APIs.
It's not that bad actually...

DirectoryEntry root = new DirectoryEntry(_ldaplocation, _serviceUserName, _servicePassword, AuthenticationTypes.ServerBind)
DirectorySearcher searcher = new DirectorySearcher(root);
searcher.Filter = string.Format("(&(objectClass=person)(businesscategory={0}))", businessCategory);
SearchResultCollection results = searcher.FindAll();
foreach (SearchResult result in results)// process each user
{
string searchpath = result.Path;
ResultPropertyCollection rpc = result.Properties;
ProcessUser(rpc);// you got your properties
}
ProcessUser(...)
{
Microsoft.Office.Server.UserProfiles.UserProfile newProfile = profileManager.CreateUserProfile(userID,PreferredName);
newProfile [PropertyConstants.FirstName].Add("FirstName");
newProfile [PropertyConstants.LastName].Add("LastName");
newProfile.Commit();
}

you can use BDC for this purpose as well.

Note : If this helped you, please add a comment and share the link as it will motivate me to post more solutions like this.

SharePoint 2010 - why should you consider creating termsets with code


Creating termsets in 2010 is very simple.
Create an csv file with the correct format (Term Set Name,Term Set Description,LCID,Available for Tagging,Term Description,Level 1 Term,Level 2 Term,Level 3 Term,Level 4 Term,Level 5 Term,Level 6 Term,Level 7 Term,GUID)
I really like this new feature and the OOTB control that you can use with termsets.

But if you are not very careful when you use termsets in your project if you are planning to use SharePoint backup/restore as a deployment mechanism. as these termsets are not part of content database, you will need to manually create the termset on the destination server.
Now...the problem is, SharePoint assign a GUID (oooh yes) to each term when you create termsets sing csv file impoerts. When you create the same termsets on your destination server, SharePoint will assign a different set of GUIDs. This means the data won't identify the terms and you need to fix them manually.
the solution is to use code to create termsets and assign GUIDs when you create them. you can use the method below for that.
public TermSet CreateTermSet(string name, Guid newTermSetId, int lcid);
Namespace : Microsoft.SharePoint.Taxonomy
class : Group
Have fun coding...

C++ and windows


Looks like C++ is back in action for windows.
It's exciting news and making me seriously consider going back to full time development.
Lets see how it goes
Check out this Channel 9 Video

SharePoint 2010 Managed Metadata Exception


SharePoint 2010 Managed Metadata Exception
if you get the following SharePoint 2010 exception , the probable reasons are
1. You are accessing the managed metadata service with a wrong name.
2. The term group you trying to access don't exist
3. The termset name is wrong.
4. the account you use don't have permissions to access the termset.
System.ArgumentOutOfRangeException was unhandled by user code
Message=Specified argument was out of the range of valid values.
Parameter name: index
Source=Microsoft.SharePoint.Taxonomy
ParamName=index
StackTrace: at Microsoft.SharePoint.Taxonomy.Generic.IndexedCollection`1.get_Item(String index)
Hope this saved you some time

How to fix SharePoint 2010 not accepting credentials


SharePoint 2010 not accepting credentials.
Follow the link below step by step. I used "Method 2" When you create the registry entry, make sue you use DWORD 32 bit and restart the server after creating the entry.
Below note is for folks like me who don't want to click on another link :)

Method 1: Specify host names (Preferred method if NTLM authentication is desired)
To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
Set the
DisableStrictNameChecking
registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Right-click MSV1_0, point to New, and then click Multi-String Value.
Type BackConnectionHostNames, and then press ENTER.
Right-click BackConnectionHostNames, and then click Modify.
In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
Quit Registry Editor, and then restart the IISAdmin service.
Back to the top
Method 2: Disable the loopback check (less-recommended method)
The second method is to disable the loopback check by setting the DisableLoopbackCheck registry key.
To set the DisableLoopbackCheck registry key, follow these steps:
Set the

DisableStrictNameChecking
registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Right-click Lsa, point to New, and then click DWORD Value.
Type DisableLoopbackCheck, and then press ENTER.
Right-click DisableLoopbackCheck, and then click Modify.
In the Value data box, type 1, and then click OK.
Quit Registry Editor, and then restart your computer.

Note : If this helped you, please add a comment and share the link as it will motivate me to post more solutions like this.