March 31, 2010

SharePoint Master Page

<%-- Identifies this page as a .master page written in Microsoft Visual C# and registers tag prefixes, namespaces, assemblies, and controls. --%>
<%@ Master language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>
<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>
<%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %>
<%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu" src="~/_controltemplates/PublishingActionMenu.ascx" %>
<%-- Uses the Microsoft Office namespace and schema. --%>
<html>
<WebPartPages:SPWebPartManager runat="server"/>
<SharePoint:RobotsMetaTag runat="server"/>

<%-- The head section includes a content placeholder for the page title and links to CSS and ECMAScript (JScript, JavaScript) files that run on the server. --%>
<head runat="server">
<asp:ContentPlaceHolder runat="server" id="head">
<title>
<asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server" />
</title>
</asp:ContentPlaceHolder>
<Sharepoint:CssLink runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
</head>

<%-- When loading the body of the .master page, SharePoint Server 2007 also loads the SpBodyOnLoadWrapper class. This class handles .js calls for the master page. --%>
<body onload="javascript:_spBodyOnLoadWrapper();">
<%-- The SPWebPartManager manages all of the Web part controls, functionality, and events that occur on a Web page. --%>
<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<wssuc:Welcome id="explitLogout" runat="server"/>
<PublishingSiteAction:SiteActionMenu runat="server"/>
<PublishingWebControls:AuthoringContainer id="authoringcontrols" runat="server">
<PublishingConsole:Console runat="server" />
</PublishingWebControls:AuthoringContainer>
<%-- The PlaceHolderMain content placeholder defines where to place the page content for all the content from the page layout. The page layout can overwrite any content placeholder from the master page. Example: The PlaceHolderLeftNavBar can overwrite the left navigation bar. --%>
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
<asp:Panel visible="false" runat="server">
<%-- These ContentPlaceHolders ensure all default SharePoint Server pages render with this master page. If the system master page is set to any default master page, the only content placeholders required are those that are overridden by your page layouts. --%>
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat ="server" />
<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server" />
</asp:Panel>
</form>
</body>
</html>

March 29, 2010

IIS Redirect IIS 6 and IIS 7

ha ha...lots of hours and unexpectedly fixed the issue of IIS redirect.

Scenario:
1. Website URL is http://Server:Port/Sites/SiteName
2. User wants to type only http://Server:Port
Note: No Site Exists in Root, All Sites Exist under /Sites..

Resolution on IIS 6.0
1. Go to Properties of the IIS Virtual Directory of our Folder.
2. Home Directory
3. Select: A redirection to URL
4. Redirect to: /Sites/SiteName
5. Check: A directory below URL entered
6. Apply and Test.

Resolution on IIS 7.0
1. Go to Properties of the IIS Virtual Directory of our Folder.
2. In the Right Pane where all Propeties Listed, Double Click HTTP redirect
3. Check: Redirect requests to this destination
4. Redirect to: /Sites/SiteName
5. Check: Only redirect requests to content in this directory (not subdirectories)
6. Apply and Test.

March 25, 2010

Send Email Using Command Line - Telnet

1. Open Command Prompt
2. telnet EmalExchangeServer 25
3. HELO EmailExchangeServer
4. MAIL FROM:YourEmailAddress.........[May Get Reply "250 ok"]
5. RCPT TO:EmailAddress1,EmailAddress2 etc..[May Get Reply "250 ok"]
6. To Write Message, DATA
7. SUBJECT:YourSubject[Enter TWice]
8. Type the Message you Want
9. Put a single period (.) on a line by itself and press Enter to send your message. The server should say 'Message accepted for delivery'.
(Or it says 250 OK id=`a long id`)
8. QUIT to exit telnet

March 24, 2010

Windows and Forms Authentication

1. Create or Extend a Web Application.
2. Deployed CKS.FBA for Forms Based Authentication.
3. Modified Parser Paths in Web.Config if any of the master page has c# code in it.
<PageParserPaths>
<PageParserPath VirtualPath="/_catalogs/masterpage/Home.master" CompilationMode="Always" AllowServerSideScript="true">
</PageParserPath>
<PageParserPath VirtualPath="/_catalogs/masterpage/Home_Template.master" CompilationMode="Always" AllowServerSideScript="true">
</PageParserPath>
<PageParserPath VirtualPath="/_catalogs/masterpage/InnerPage.master" CompilationMode="Always" AllowServerSideScript="true">
</PageParserPath>
</PageParserPaths>
4. Added Safe Controls
5. Browse to C:\Windows\Microsoft.NET\Framework64\v2.0.50727
6. Run Aspnet_regsql.exe and create a database for Membership Provider.
7. Add Membership Provider information in web.config along with the Connection String
<connectionStrings>
<add name="FBAConnectionString" connectionString="Data Source=DBServerName ;Initial Catalog=DBName;Integrated Security=True" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<!-- membership provider -->
<membership defaultProvider="FBAMember">
<providers>
<add connectionStringName="FBAConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="FBAMember" type="System.Web.Security.SqlMembershipProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<!-- role provider -->
<roleManager enabled="true" defaultProvider="FBARole">
<providers>
<add connectionStringName="FBAConnectionString" applicationName="/" name="FBARole" type="System.Web.Security.SqlRoleProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<securityPolicy>
Note: All the web.config changes are needed to restore an already application, otherwise no touching on Web.Config needed other than Membership Provider.
8. Extend the Application
9. Authentication Provider, Set to Forms and Give the Name of the Provider which you mentioned in Web.config
10.All Membership additions in web.config should also be added in central admin Port also.
11. Add Users in Extended Application through IIS, .Net Users.
12. In Central Admin, Keep one FBA User as Collection Adminisatrtor (Important)
13. Now Have Fun with Windows and Forms
14. Error: Unknown Error mostly is because the secondary site collection adminsiatrtor is not set with fba user., add it in central admin and you will be fine.

Object reference not set to instance of an object .... while running stsadm.exe in adding the solution through wsp etc

The problem here is that the user you are logged in with does not have the required permissions for the database server.
Note: Remote Login -> Sql Server Management Studio --> Connect to Database --> Logins --> New Login --> Mappings, Server Roles etc.
Note: In User Mappings, Give db_owner role for all the databases needed.
If you run this with the same account as you installed your web applications with, there should be no problem.
You will need full control to the content database.
stsadm always uses credentials of the logged in user, unless offcourse you open your command prompt like this “runas /user:mydomain\myuser cmd.exe”.
Exchange mydomain and myuser with the values for the user you want to open a command prompt as.

March 18, 2010

Eye Excercises

The Cure: Eye exercise : The following exercises will loosen the strained and contracted muscles surrounding the eyes :

a. Keep your head still and relaxed. Gently move the eyes up and down six times. Repeat the same movement twice or thrice at 2-second intervals. The eyes should move slowly and regularly as far down as possible and then as far up as possible.

b. Move the eyes from side to side as far as possible, without any force or effort six times. Repeat two or three times.

c. Hold the index finger of your right hand about 8 inches in front of the eyes, then look from the finger to any other large object ten or more feet away - the door or window will do. Look from one to the other 10 times. Do this exercise fairly rapidly.

d. Move the eyes up gently and slowly in a circle, then move them low in the reverse direction. Do this four times in all. Rest for a second and repeat the movements two or three times, using minimum efforts. All eye muscle exercises should be performed while seated in a comfortable position.

Neck Exercises: Rotate the neck.

a. In circles and semi circles.

b. Move the shoulders clockwise and anti-clockwise brisky, drawing them up as far as possible several times.

c. Allow the head to draw forward and backward as far as possible.

d. Turn the head to the right and left as far as possible several times. These exercises help to loosen up contracted neck muscles which may restrict blood supply to the head.

Sun gazing: Sit on a bench facing the sun with your eyes closed and gently sway sideways several times for 18 minutes. Open the eyes and blink about ten times at the sun and look at some greenery. This helps short sight and is good for inflamed eyes.

Splashing: Splash plain, cold water several times on closed eyes. Rub the closed lids briskly for a minute with a clean towel. This cools the eyes and boosts blood supply.

Palming: Sit comfortably in an armchair or on a settee and relax with your eyes closed. Cover your eyes with your palm, right palm over the right eye and left over the left eye. Do not, however, press down on the eyes. With your eyes completely covered in this manner, allow your elbows to drop to your knees, which should be fairly close together. With your eyes closed thus, try to imagine blackness, which grows blacker and blacker. Palming reduces strain and relaxes the eyes and its surrounding tissues.

Swinging: Stand with your feet 12 inches apart, hands held loosely at the sides, the whole body and mind relaxed. Gently sway your body from side to side, slowly, steadily, with the heels rising alternatively but not the rest of the foot. Imagine you are the pendulum of the clock, and move just as slowly. Swinging should be done in front of a window or a picture. You will see the object moving in the opposite direction of your swing. This must be noted and encouraged. When you face one end of the window or object, blink once. This exercise has a very beneficial effect upon the eyes and nervous system.

Diet: Natural, uncooked foods are the best diet. These include fresh fruits, such as oranges, apples, grapes, peaches, plums, cherries; green vegetable like lettuce, cabbage, spinach, turnip tops; root vegetables like potatoes, turnips, carrot, onions and beetroots; nuts, dried fruits and dairy products.

Cereals are also necessary, but they should only be consumed sparingly. Genuine whole meal bread is the best and most suitable. Nans, cakes, pastries, white sugar, white bread, confectionary, tea, coffee, etc., together with meat, fish, or eggs, soon play havoc with digestion and the body.

The value of vitamin A for improving vision must be stressed. The intake of sufficient quantities of this vitamin is essential as a safeguard against or treatment of defective vision or eye disease of any kind. The best sources of this vitamin are cod liver oil, raw spinach, turnip tops, cream, cheese, butter, egg yolk, tomatoes, lettuce, carrot, cabbage, soya beans, green peas, wheat germ, fresh milk, oranges, and dates.

Yogic exercises: Trataka: In yoga, four exercises have been prescribed for strengthening weak eye muscles, relieving eyestrain and curing of eye disease. They are known as ‘ Trataka‘, which in sanskrit means "Winkles gaze at a particular point" or looking at an object with awareness. The four tratakas are: Dakshinay jatru trataka in which, with face forwards, the eyes are fixed on the tip of the right shoulder; Vamajatru trataka, in which the eyes are fixed on the tip of the left shoulder; Namikagra trataka, in which the eyes are focussed on the tip of the nose, and Bhrumadhya trataka, in which the eyes are focussed on the space between the eyebrows. These exercises should be practiced from a meditative position like padmasana or vajrasana. The gaze should be maintained for as long as you are comfortable, gradually increasing the period from 10-20 and then to 30 seconds. The eyes should be closed and rested after each exercise. Persons with acute myopia should perform the tratakas with their eyes closed.

March 17, 2010

Defaulting People Picker in aspx pages to Current User

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("fillDefaultValues");

function fillDefaultValues()
{
fillPeoplePickerWithCurrentUser('Submitted_x0020_By');
}

function fillPeoplePickerWithCurrentUser(pickerName)
{
//get the current user from the welcome menu
var currentUser = getCurrentUser();

//check to see that we've got it
if(currentUser != null)
{
//get the people pickers input div
var pp = getPickerInputElement(pickerName);
//set it to the current user if we've found it
if(pp != null)
pp.innerHTML = currentUser;
}
}

function getCurrentUser()
{
var tags = document.getElementsByTagName('a');
for (var i=0; i < tags.length; i++)
{
if(tags[i].innerText.substr(0,7) == 'Welcome')
{
return tags[i].innerText.substr(8,tags[i].innerText.length);
}
}
}

function getPickerInputElement(fieldsInternalName)
{
var result = "";
var divs = document.getElementsByTagName("DIV");
for(var i=0; i < divs.length ; i++)
{
if(divs[i].id=="WebPartWPQ2")
{
var tds = divs[i].getElementsByTagName("TD");
for(var j=0; j < tds.length; j++)
{
var cellHTML = tds[j].innerHTML;
if(cellHTML.indexOf('FieldInternalName="' + fieldsInternalName + '"') >= 0)
{
var innerDivs = tds[j].getElementsByTagName("DIV");
for(var k=0; k < innerDivs .length; k++)
{
if(innerDivs[k].id.indexOf("UserField_upLevelDiv") > 0)
{
result = innerDivs[k];
break;
}
}
}
}
}
}
return result;
}
</script>

Defaulting a SPFieldLink like All Day Event in Calender

Use a Console Applicationa and run this.

// Don’t forget this
using System.Reflection;
...
using(SPSite site =
new SPSite("http://yoursite"))
{
using(SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Calendar"];
SPContentType ct = list.ContentTypes["Event"];
SPFieldLink fieldLink = ct.FieldLinks["All Day Event"];
// Now comes the magic
Type type = typeof(SPFieldLink);
PropertyInfo pi = type.GetProperty("Default", BindingFlags.NonPublic | BindingFlags.Instance);
pi.SetValue(fieldLink, "1", null);
ct.Update();
}
}

March 12, 2010

SharePoint_Tips_Utility_Pack

http://www.codeplex.com/spstipsUtilityPack

For:

1. Look Up defalut Value
2. Show/Hide in forms
3. etc etc in managing Doc Library and Lists

March 05, 2010

Content Types in Sharepoint

1. One Content Type - One Metadata
2. A Document in a Doc Library can be associated to any number of the Content Types we desire.
3. Site Content Types are like Master Page/ Template which will be used in the Site.
4. Once a Doc Lib is associated to the Content Type, The Coulmns in that Content Type will now behave as Local version of that Doc Library.
5. You can Override the Values, Defaults, Req, Optional etc.
6. Limitation is if we want to attach two Content Types to One Doc Library and want the Column to behave differently in either Content Type, we cannot do that Coz it became a Local Version but in both Content Types.
7. If we want the Site Column to behave differently then a Separate Doc Library should be maintained.

March 03, 2010

Dynamic Redirect for a User

FormsAuthentication.RedirectFromLoginPage(txtUserName.Text.Trim(), false);
string strUserUrl = "";
SPSecurity.RunWithElevatedPrivileges(delegate
{
SPSite oSite = SPContext.Current.Site;
SPWebCollection collWebs = oSite.OpenWeb().GetSubwebsForCurrentUser();
foreach (SPWeb oWebsite in collWebs)
{
SPUserCollection collUsers = oWebsite.AllUsers;
foreach (SPUser oUser in collUsers)
{
if (oUser.LoginName.ToUpper() == txtUserName.Text.Trim().ToUpper())
{
strUserUrl = oWebsite.ServerRelativeUrl.ToString();
}
}

oWebsite.Dispose();
}
});

Response.Redirect("http://portal/"+strUserUrl,true);

March 02, 2010

Backup - Restore - STSADM - SharePoint Site

Backups are useful when moving from one Environment to another.
It will bring all the Data,Users,Permissions etc.

1. Run-->Cmd --> cd C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
2. stsadm -o backup -filename TestNameWithDate.dat -url http://WorkingURL
3. stsadm -o restore -filename TestNameWithDate.dat -url http://TargetURL -overwrite
4. Usually all Safe Controls will come in Web.Config but if something is breaking, check the Web.Config for safe controls.
5. If Content Types are not visible, Refresh/Restart the Application Pool and Site

Different Ways:

1. From Server : stsadm -o backup -filename TestNameWithDate.dat -url http://SiteURL
2. From SharePoint Designer 2007 (Recommended)
Steps:
1. Open the site in SharePoint Designer
2. Go to the site which you want to take BackUp
3. Site  Administartion  BackUp Website  ok  Save to your desktop location or anywhere
4. It will generate a .CMP file and that’s our backup which we can restore in the same way.
3. From the Site itself.
Steps:
1. Go to any site.
2. Make sure you are inside the site.
3. Now, Go to SiteActions  SiteSettings  Modify All Site Settings
4. Once you are here, In the browser URL, instead of settings.aspx access savetmpl.aspx
5. This will give you to save site as a Template(.stp file saved in site galleries of the root level site)

Custom Permission Levels - For a Normal restricted User

First Check the Site Permissions:
1. View Usage Data - View reports on Web site usage.
2. Browse Directories - Enumerate files and folders in a Web site using SharePoint Designer and Web DAV interfaces.
3. View Pages - View pages in a Web site.
4. Enumerate Permissions - Enumerate permissions on the Web site, list, folder, document, or list item.
5. Browse User Information - View information about users of the Web site.
6. Use Remote Interfaces - Use SOAP, Web DAV, or SharePoint Designer interfaces to access the Web site.
7. Use Client Integration Features - Use features which launch client applications. Without this permission, users will have to work on documents locally and upload their changes.
8. Open - Allows users to open a Web site, list, or folder in order to access items inside that container.
9. Edit Personal User Information - Allows a user to change his or her own user information, such as adding a picture.
List Permissions:
1. Add Items - Add items to lists, add documents to document libraries, and add Web discussion comments.
2. Delete Items - Delete items from a list, documents from a document library, and Web discussion comments in documents.
3. View Items - View items in lists, documents in document libraries, and view Web discussion comments.
4. Open Items - View the source of documents with server-side file handlers.
5. View Versions - View past versions of a list item or document.
6. Delete Versions - Delete past versions of a list item or document.
7. View Application Pages - View forms, views, and application pages. Enumerate lists.
Notes:
1. Modify Shared Web Part will come when user has edit access.
2. Access denied can come when he doesn't have View Application Pages Permission.
3. Delete will show up but when clicked acces denied will come, this is due to the user doesn't have delete versions, view versions permission when versioning has been enabled.

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...