Skip to main content

Posts

PATH OF DOOM

Disable Loopback Check

There is a security check in Windows 2008 which was introduced since the 2003 server version. This check ensures that a web application cannot be accessed using a fully qualified domain name on the host machine.  If you try to do so, the system returns an access denied error (401.1 error).  In actual fact, the login even though is correct will get challenged and produce a logon failure if you check the event log. The way to fix it is to make changes to the registry by following the steps below: Login to the Windows File Server Open regedit Allow other machines to access share using aliases Change Disable Strict Name Checking in the registry Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters Add a DWORD named DisableStrictNameChecking Set value to 1 Also Proceed to HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name “BackConnectionHostNames” and add the FQDN of the web application to it.  

Copy files from a document library to a files system by looping through all folders and subfolders in a library

If you have a need to copy file files from a document library to a SharePoint files system specifically the layouts folder.      private void LoopSubFolders(string folderPath, SPFolderCollection subFolders)         {             string templatePath = SPUtility.GetGenericSetupPath("TEMPLATE");             string FolderPath = Path.Combine(templatePath, @"LAYOUTS\ATP\");             try             {                 foreach (SPFolder folder in subFolders)                 {                     if (folder.Name.ToLower() != "forms")                     {                         string folderN...

Delete all files and folders in a document library

Are you looking to delete all files and folders in a document library, look no further. Ensure your users are empowered to do so by elevating their privilege, allow unsafe update then loop through the library in question. SPSecurity.RunWithElevatedPrivileges(delegate()             {                 using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID))                 {                     using (SPWeb web = elevatedSite.RootWeb)                     {                         web.AllowUnsafeUpdates = true;                         web.ValidateFormDigest();                         ...

Download a file from a document library

You can download a file from a file stream quickly by passing in a SPFile object and the path where you want it to be written to: static void DownloadFileUsingFileStream(SPFile file, string path)         {             byte[] filecontent = file.OpenBinary();             FileStream fs = new FileStream(path + file.Name, FileMode.CreateNew);             using (fs)             {                 BinaryWriter bw = new BinaryWriter(fs);                 bw.Write(filecontent, 0, filecontent.Length);                 bw.Close();             }         } QED

Add Web Visual Studio templates to SharePoint Project

Would you like to add the web user control to SharePoint 2007 project development.  Then open the project file with notepad and add {349c5851-65df-11da-9384-00065b846f21} to the ProjectTypeGUIDs node.   The necessary change is shown below: < ProjectTypeGuids > {349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} </ ProjectTypeGuids >