Sharepoint Insight by Namwar Rizvi

Sharepoint Tips, Tricks and inside knowledge from real world experience by Namwar Rizvi

Archive for July, 2008

How to get SPUser (User) from Person or Group field of Sharepoint List

Posted by namwar on July 26, 2008


While writing document event handler, sometimes we need to to process the logic based on the value of Person or Group field. Sharepoint stores ID of the user in Person or Group field and there is no obvious way to get the SPUser object from this ID because this ID is stored as ID field in the userinfo and userdata tables. Following function is the qucikest way to get SPUser object from ID. Call this function with

  1. the name of the Sharepoint list where your event is fired and
  2. SPItemEventProperties object which has been passed to you as your event arguments
public SPUser GetSPUserFromID(string listName, SPItemEventProperties properties)
{
SPFieldUser userField = (SPFieldUser)properties.OpenWeb().Lists[listName].Fields.GetField(accountNameField);
SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(currentValue);
SPUser user = fieldValue.User;
return user;
}

Posted in Event Handler | Tagged: , | 9 Comments »

How to get rid of Login prompt while opening documents in Microsoft Office

Posted by namwar on July 18, 2008


If you are using Sharepoint as your document repository, you may came across with a situation where your users are prompted for login credentials whenever they try to open any document of document library in Microsoft Word. This is very irritating and can ruin the objective of user productivity.

You can resolve this issue very easily. It happens actually if your Sharepoint site is not in the trusted zone of IE. You can verify this by looking at the bottom right of your browser window as follows:

Internet zone icon

If you see the word “local intranet” or “Trusted sites” then only you can open your documents without getting prompt of login credentials. Just add your Sharepoint site into the “Trusted sites” zone and bingo! MS Word will stop prompting you for your credentials. Enjoy!

Posted in Security, Uncategorized | Tagged: | 4 Comments »

Registry setting for Sharepoint Configuration Database connection string

Posted by namwar on July 16, 2008


Ever wondered where does Sharepoint saves its configuration database connection information? Sharepoint 2007 saves its connection string for configuration database in registry and you can change it easily if you have moved your configuration database from one server to another. Following is the registry path

My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb

and our required key is dsn

Posted in Configuration | Tagged: , | 6 Comments »