Monday, October 28, 2013

Anonymous access to a site


  • Goto Central and click on Webapplication in which you want anonymous access

  • Click on Authentication Providers and click on Default Zone
  • Select "Enable Anonymous Access

  • click OK
  • click on Anonymous Policy

  • and select "Deny - Write" in my case I dont want anonymous users to modify the site. 
  • select the site in the webapplication which you want "Anonymous access" enabled and got Site Permissions. Clikc on "Anaonymous Access " button on top

  • Choose "Entire Website" and click OK.

Friday, October 25, 2013

Integration of Project Server with Team Foundation Server in simple steps and solutions to most common issues

Integration of Project Server 2010, TFS 2010 tips and tricks - Part 1

  • Softwares required 
TFS 2010 server (with SP1), Visual Studio 2010 (with SP1), Project Professional 2010,  Project Server 2010 (with SP1), make sure the webapp for the instance of PWA is set to classic mode authentication. The way to check it is
                       PS C:\Users\PS_FarmAdmin_SVC> $web = Get-SpWebApplication "http://mismsprojsrv/"
                       PS C:\Users\PS_FarmAdmin_SVC> $web.UseClaimsAuthentication
                       False  {False value indicates that is classic mode, not claims based}
Need to download 64-bit Feature Pack for TFS and Project Server integration. We already had couple of Visual Studio Ultimate licenses , so we could download it from MSDN.
  •  Modify the C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config for SharePoint site of Project server (My webapp for PS was running on port 80). Add dependentAssembly for Project.Server.Library
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      ...........
................
      <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Microsoft.Office.Project.Server.Library" publicKeyToken="71e9bce111e9429c" culture="neutral" />
        <bindingRedirect oldVersion="12.0.0.0" newVersion="14.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  • If you Project server was installed on existing farm on multiple application servers of the farm, Run the SharePoint configuration wizard on all of them. If you have an independent server for Project server, you just run the wizard on that server after all the updates and SP's are installed.
  • I create a separate PWA called PEIMS for this
    • Goto SharePoint Admin,  Project Server Service application
    • Create Project WebApp Site PWAPEIMS
  • I also created a Project called "Magnet" in Project Professional and published it to Project Server
  • Created a Team Project Collection, using the create Team Project collection on TFS Admin Console








      ·         The TFS server URL is http://mistfs:8080/tfs,  the URL for the Project Web App instance  used for this integration is http://mismsprojsrv/PWAPEIMS/   and the team project collection we are going to use is http://mistfs:8080/tfs/PEIMS

      ·         This is the most important part of the integration, Tasks in Project Server are synchronized with types of work items in TFS

      o   Team project types of work items to synchronize Project server tasks. Let’s synchronize User Stories and Tasks, as those are the most common types that are synchronized in team projects that are based on the process template for agile projects.

      o   The synchronization and field mapping are specified in Part 2 and posted separately in the Part #2.






       

Friday, February 8, 2013

Powershell script to modify links in SharePoint 2010 list


#To change List Items with Hyperlinks
$webURL = "http://website URL/"
$listName = "VendorContracts"
$fieldName = "File Link"
$web = Get-SpWeb $webURL
$list = $web.Lists[$listName]

foreach ($item in $list.Items)
{
$url = $item[$fieldName]
write-host $url
$url = $url -replace "string to be replace" , "new string"
$item[$fieldName] = $url
$item.Update()
write-host $item[$fieldName]
}

Monday, July 30, 2012

Webpart to read passwords from KeePass database

Developed a webpart which gets the data from KeePass database and displays it to the secured users. I wanted to share the code to other users, so that it makes it easy for them develop and they don't have to jump through the same hoops as I did.


I did my business processing in WCF service and the validation and security checks on my webpart.
The gist of the wcf service which is calling the KeePass software to get the details of groups and other information from KeePass is below.


 public class PswdService : IPswdService
    {
        public List<dbVal> GetData(string masterpw, string pswdFilePath {
            try  {
                var ioConnInfo = new IOConnectionInfo { Path = pswdFilePath };
                var compKey = new CompositeKey();
                compKey.AddUserKey(new KcpPassword(masterpw));
                var db = new KeePassLib.PwDatabase();
                db.Open(ioConnInfo, compKey, null);
                List<dbVal> kpdata = (from entry in db.RootGroup.GetEntries(true)
                                      select new dbVal
                                      {
                                          Group = entry.ParentGroup.Name,
                                          ParentGroupPath = entry.ParentGroup.GetFullPath("/", true),
                                          Title = entry.Strings.ReadSafe("Title"),
                                          Username = entry.Strings.ReadSafe("UserName"),
                                          Password = entry.Strings.ReadSafe("Password"),
                                          URL = entry.Strings.ReadSafe("URL"),
                                          Notes = entry.Strings.ReadSafe("Notes")
                                      }).ToList();
                List<dbVal> lstDbVal = kpdata.ToList();
                db.Close();
                return lstDbVal;
            }
            catch (Exception ex)

In my webpart, I am calling the wcf service and based on the user selection, I am showing the results. I have not included the code for user selections, as it is pretty straight forward.


 masterList = new List<GetPasswords.dbVal>();
                GetPasswords.PswdServiceClient wcfClient = new GetPasswords.PswdServiceClient();
                wcfClient.Open();
                masterList = (List<GetPasswords.dbVal>)wcfClient.GetData(masterPswd, parentWebPart.KeePassFilePath);
                wcfClient.Close();
                if (masterList == null)     //Invalid password   
                {
                    MessageLabel.Text = "Invalid Password, no password records returned, Please try again.";
                    return;
                }
                parentWebPart.PswdDetails = null;
                parentWebPart.PswdDetails = new List<GetPasswords.dbVal>(masterList);
                parentWebPart.SaveProperties();
                string[] parentpath;
                List<string> ProductList = new List<string>();
                int count;
                foreach (GetPasswords.dbVal dbValObj in masterList)  {
                    count = dbValObj.ParentGroupPath.Count(f => f == '/');
                    if (count >= 2)
                    {
                        parentpath = dbValObj.ParentGroupPath.Split('/');
                        ProductList.Add(parentpath[PRODUCT]);
                    }
                }
                ProductCombo.DataSource = ProductList.Distinct();
                ProductCombo.DataBind();
                ProductCombo.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                ProductCombo.SelectedIndex = 0;
                MessageLabel.Text = "Please select Product ";



Hope this is helpful for you guys. With KeePass API, you can do a lot more things. If you want to explore more, goto http://keepass.info/index.html and download the tool and there code.

I want to acknowledge the help of Ronnie Overby  for his help on KeePass.



Thursday, December 15, 2011

List all files in document library along with file sizes

Created a Powershell script to list all the files and there sizes into a comma separated file.

<# .SYNOPSIS Checks file sizes in a SharePoint document library and write them into comma separated file. #>
Add-PSSnapin Microsoft.SharePoint.PowerShell

$url = "your sharepoint site path"

$spAssignment = Start-SPAssignment


$strPath="$env:UserProfile\Documents\FileSizes.txt"
Add-Content $strPath "`n FileName , Size , Access Denied"
$spWeb = Get-SPWeb $url -AssignmentCollection $spAssignment

# Get the folder
$spFolder = $spWeb.GetFolder("Shared Documents")

# Store file collection in a variable

function FileParser([Microsoft.SharePoint.SPFolder]$spFolder)
{
$spQuery = new-Object Microsoft.SharePoint.SPQuery
$spQuery.Folder = $spFolder

$spWeb = $spFolder.ParentWeb

$spList = $spWeb.Lists[$spFolder.ParentListId]

$spItemCollection = $spList.GetItems($spQuery)


foreach ($spItem in $spItemCollection)

{

# If the item is a folder
Try
{
if ($spItem.Folder -ne $null)

{

# Write the Subfolder information

Write-Host("Folder: " + $spItem.Name + " Parent Folder: " + $spFolder.Name)

# Call the Get-Items function recursively for the found sub-solder

FileParser $spItem.Folder

}

# If the item is not a folder
if ($spItem.Folder -eq $null)
{

Write-Host("File: " + $spItem.File + " Size " + $spItem.File.Length)
$size = $spItem.File.Length.ToString()
$filepathName = $spItem.File.ToString()
$strLine = $filepathName + " , " + $size
Add-Content $strPath $strLine
}
}
Catch {
Write-Host("Error : $_ ")
Add-Content $strPath "$_"
}

}

$spWeb.dispose()

$spWeb = $null

}

FileParser $spFolder


$a = $null
[GC]::Collect()

Stop-SPAssignment $spAssignment

<# Acknowledgement: Part of the logic was taken from Paul King's blog http://blogs.msdn.com/b/paulking/ #>

Sunday, August 21, 2011

Group policy Management tool missing

If the gpmc.msc file (Group policy management tool is not present) on your server, you enable the future by following this link
http://blogs.technet.com/b/askds/archive/2008/07/07/installing-gpmc-on-windows-server-2008-and-windows-vista-service-pack-1.aspx

Thursday, August 11, 2011

Sharepoint 2010 development environment setup on Windows 7


 Make sure you have admin access on the pc where you are going to setup the sharepoint development environment. 

1.       You should preferably be running Windows 7 on x64 capable CPU and minimum RAM is 2GB, but I would suggest that we at least have 4GB for better performance.

2.       Install Visual Studio 2010 Enterprise edition and SQL Server Developer edition, This will get most of the prerequisites. You could also install the express editions of Visual Studio and SQL Server, but I haven’t tried with them.

3.       Download SharePoint 2010 foundation at
Or trail version at
Or in fact you could use your companies Subscription downloads for getting the Enterprise SharePoint 2010.

4.       Copy the SharePointFoundation.exe (or setup.exe for SharePoint enterprise edition) installation file to a temp folder on your computer C:\Temp
Open a command window
For SharePoint Foundation 2010:
c:\temp\SharePointFoundation.exe /extract:c:\temp5.       Open following file in notepad
c:\temp\files\Setup> notepad config.xml
Add following line to <configuration> tag
<Setting Id="AllowWindowsClientInstall" Value="True"/>
and save
The configuration for foundation should look like this, It is case sensitive
<Configuration>
  <Package Id="sts">
    <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL" />
  </Package>
  <DATADIR Value="%CommonProgramFiles%\Microsoft Shared\Web Server
   Extensions\14\Data" />
  <Logging Type="verbose" Path="%temp%" Template="Microsoft SharePoint Foundation 2010 Setup *.log" />
  <Setting Id="UsingUIInstallMode" Value="1" />
  <Setting Id="SETUP_REBOOT" Value="Never" />
  <Setting Id="AllowWindowsClientInstall" Value="True"/>
</Configuration>
 
6.   Install the following additional prerequisites
(a)     Microsoft FilterPack 2.0. At a command prompt, execute FilterPack.msi file
c:\temp\PrerequisiteInstallerFiles\FilterPack\FilterPack.msi
(b)    Microsoft Sync Framework (http://go.microsoft.com/fwlink/?LinkID=141237)
(c ) SQL Server Native Client (http://go.microsoft.com/fwlink/?LinkId=123718)
(e) Chart Controls (this is not required if you are going to install SharePoint Foundation 2010). (http://go.microsoft.com/fwlink/?LinkID=122517)
(f) SQL Server Analysis Services - ADOMD.Net (this is not required if you are going to install SharePoint Foundation 2010).
(g)    This should already be preinstalled with Visual Studio 2010
Install WCF hotfix on pc (Windows6.1-KB976462-v2-x64.msu)

(h)   This should already be preinstalled with Visual Studio 2010
Install the ADO.NET Data Services Update for .NET Framework 3.5 SP1 to enable REST-based data services
Download and install Windows6.1-KB982307-x64.msu
(i)      If you are using local version of SQL Server 2008,
Install the service pack1
Download and install Windows6.1-KB982307-x64.msu


7.       Manually enable each of the required Windows Features. You can do this quickly by copying and running the following command in a Command Prompt window.
C:\temp> start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ManagementScriptingTools;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;WCF-NonHTTP-Activation
Or
Download following file and run it in dos window at c:\temp
8.  Verify that following features are enabled in IIS
required features in the Internet Information Services section of the Windows Features dialog box (whih you can access through the Programs section in Control Panel). 
If any features are missing in your operating system, return to theInternet Information Services section of the Windows Features dialog box and enable them.
 
9.  Click on Control Panel -> Programs Section.
Select “Turn Windows Features on or off”

Verify following features under Internet Information Services are enabled, Typically with the script they should automatically be enabled.

10.   Restart computer by entering
Shutdown –t 0 –r –f
Where
–t 0 : shutdown in 0 seconds
-r : restart after shutdown
-f : force all application to terminate.

11.   Run C:\temp\setup.exe

12.   On the Choose the installation you want page, click Standalone 

13.   For any errors on install, see the log file
14.    To find the log file, open a Command Prompt window, and then type the following commands at the command prompt. The log file is displayed at the end of the directory listing.
cd %temp%
This will take you the local temp directory, in my case it was
C:\Users\loginname\AppData\Local\Temp>
dir /od *.log
This will show logs file ordered by date, the main logs which we would be interested are 
C:\Users\loginame\AppData\Local\Temp>notepad "Microsoft SharePoint Foundation 2010 Setup 20110812145510E6C.log"
1.       After install the SharePoint 2010 config wizard opens,  if using local instance of SQL server 2008 , install service pack 1  http://support.microsoft.com/kb/970315

Before proceeding with the wizard

2.       If you want to start the configuration wizard manually, we can use
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\ psconfigui.exe