A blog about SharePoint, .NET, Digital art and drums.. Pretty much what it says on the tin.
Friday, 4 November 2011
SharePoint and DPM Protection
The domain its self has everything, domain controllers, exchange, sql cluser(s), sharepoint 2007 multi server farms, sharepoint 2010 multi server farms and plenty of single server instances to worry about. The domain is a virtualised domain with some impressive tin and plenty of resources so its used globably by the company i work for.
I've been using my increasing powershell kung fu to automate and batch most of the process but before I write some posts about what i'm doing and how - on a farm this big I needed to make sure I knew the basics of DPM and specifically doing it for Sharepoint.
I found a fantastic post that helps me do just that and wanted to share.
http://scug.be/blogs/scdpm/archive/2010/03/11/sharepoint-2010-protection-in-dpm-2010-part-1.aspx
Have fun!
Wednesday, 26 October 2011
Update SharePoint User Profile for all users in a Active Directory Distribution List
So if I am based in "Glasgow" and I am in the Active Directory Group "Scotland_All" - they wanted some code to update my user profile property, on a mass scale (12,000 users)..
I did some googling before i set about the task but didn't find very much so figured i'd post a quick how-to.
First I went through active directory to get all users that were a member of X group.
const string ADaddress = "domain.com";const string ADuserName = @"domain\admin";const string ADPassword = "DomainAdminPassword";const string ad_group = "Xgroup";const string domain_name = "Domain"; //not entirely neededconst string sp_site = "http://yourSharePointSite.domain.com";const string location_value = "Value";
I had to use an account and password with access to AD.
try{//Create connection to AD and get all users in specified groupPrincipalContext ctx = new PrincipalContext(ContextType.Domain,ADaddress,ADuserName,ADPassword);//Search for members in groupGroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, ad_group); //CL_France being the DL we needPrincipalSearchResultmembers = group.GetMembers(); //getting them all //Get the user names and add the domain (we are assuming that all these users will be "s7")foreach (Principal member in members){string domainUserName = domain_name + @"\" + member.SamAccountName;//Update in SharepointUpdatespProfile(domainUserName);}}catch (Exception ex){Console.WriteLine(ex); //show me the errorConsole.Read(); //pause}}
Once have the users details, I start updating their user profile. This is done using the object model so the console app was run locally. It can be done via web services but with so many users and transactions I found that simelar tasks would time out..
//take user names, check they have a user profile - if they do, update "localtion" fieldstatic void UpdatespProfile(string uName){//show user in consoleConsole.WriteLine(uName);//member.SamAccountName);try{using (SPSite site = new SPSite(sp_site)){//Connect to user manager and pass in user nameUserProfileManager profileManager = new UserProfileManager(ServerContext.GetContext(site));UserProfile userProfile = profileManager.GetUserProfile(uName);//check if we have a valid user profileif (userProfile != null){//Update location fielduserProfile["Location"].Value = location_value;//update the user profileuserProfile.Commit();//show it worked in consoleConsole.WriteLine("Updated Location to" +" " + location_value);}else{//show we didn't have a valid user profile in consoleConsole.WriteLine("No user profile");}}}catch (Exception ex){//show the errorConsole.WriteLine(ex);//pauseConsole.Read();}}
Works very nicely. Hope someone out there finds it useful.
Thursday, 25 August 2011
Upcoming Posts
- New Virtual Machine created from clone of base server
- New virtual machine configured
- Powershell scripted configuration of the operating system installation
- powershell scripted configuration of networking, renaming the machine, joining the domain
- Powershell scripted configuration of a Sql server 2008 pre-deployment image
- Powershell scripted installation of SharePoint 2010
- Powershell scripted configuration of SharePoint 2010 configuration database and new farm
- powershell scripted deployment of new SharePoint 2010 farm
- powershell scripted deployment of web applications and site collections
- powershell scripted configuration of SSP
- Powershell scripted configuration of search services
- powershell scripted server security configs, terminal services and so forth
- powershell scripted assignment of Alternate access mappings to allow remote access
Friday, 28 January 2011
New laptop
2.93 ghz CPU i7 Quad Core
16 GIG DDR
500 GB Hard Drive
Windows 7 Ultimate 64BIT
3GB Graphic Card
Built in Wireless
DVDRW / BluRay
UK Spec
USB 3.0 Technology
9 Cell Battery
JBL 2.1 Designed & Certified Speakers +Waves MaxxAudio®
2.1 Audio: 2 X 5W + 12W sub-woofer 22W Total
Integrated Camera
15 Months McAfee Anti Virus
Computrace LoJack so it can't get pinched :)
Tuesday, 24 August 2010
Rational Guide to implementing SharePoint Server 2010 User Profile Synchronization (Link)
As the guy says, there are tones of "guides" and tuition on this available on the net but hopefully landing here, or following here (all 2 of you) will save you the hassle. -All credit to the author, of course.
life saving!
http://www.harbar.net/articles/sp2010ups.aspx
Just remember to do the damn IIS Reset at the end lol
Ryan ;)
Wednesday, 26 May 2010
Track Any Download in SharePoint using Google Analytics
Sharepoint,Google analytics,moss2007,traffic,ryan mathieson,tracking sharepoint users,tracking sharepoint,sharepoint analytics,sharepoint downloads
Ryan Mathieson wrote:
SharePoint and Google Analytics: Track external downloads and who’s downloading them
Loads of posts available explaining how to track downloads from document libraries and lists but not external links or content links written into HTML Content fields in publishing pages. After some time fiddling around with different ideas this very basic little script can be adapted to most requirements.
My requirement was simply to track forms based authenticated users downloading PDFs using Google analytics and build a report on it. The challenge was that the downloads being tracked could be document libraries, lists, external links or files sitting in IIS (don’t ask..)
<%@ Import Namespace="Microsoft.SharePoint" %>
<script type="text/javascript">
var loginName = "<%= SPContext.Current.Web.CurrentUser.LoginName %>";
</script>
<a href="#" onClick="javascript: pageTracker._trackPageview('/downloads/PDF/' + loginName); ">
In my case i put the <script> into my page layout and in the html fields on the page, I would add the link with the onClick event. This worked perfectly.
Wednesday, 24 February 2010
Define Site-Level Search scopes using master pages
sharepoint moss search scopes master pages site level content sources custom search
Introduction
My client has a custom public facing Web Content Management SharePoint solution on the web. Their requirement is that within certain areas of this public site searches submitted by users only search the current area they are in.
To achieve this; a Search Scope was created specific to each site using Microsoft Office SharePoint Server, Shared Services provider. A search scope defines a subset of information in the search index. Normally used in the context of allowing a user to select a search scope when performing a search in order to restrict search results to within that search scope. Typically, search scopes encompass specific topics and content sources that are important and common to users in the organization and selection of the desired search scope is done using the standard SearchBox web part for MOSS providing a drop down to the user.
In our scenario; searches are taking place from one central input control on the Master Page of the site collection and our search scope selection is based definitively on the current area of the site in which the user performs the search.
Use Example: If a user navigates to: http://sharepointsite.com/subsite/contentsite/. Our user is in the current site “contentsite” which in this case is a site collection defaulting to the “/pages” with no document libraries, lists or additional content as it is a public facing SharePoint site. When a user submits a search from this site his returned results should be all pages and documents within the Trustees site and its subsites without returning unnecessary SharePoint content.
Defining Search Scopes for Public Facing SharePoint Site
our site is a public facing WCM (Web Content Management) version of SharePoint and configuring search on this site is more advanced than on an out-of-box Intranet or publishing solution. Standard SharePoints search results include all content of the site, its subsites and all of the resource content such ass CSS, JavaScript, XSL, Images, Administration list, User Profiles and more. For public facing site the search experience must only return relevant results based on the content and context of the web site.
Search Scope Configuration
Searches using these scopes will return anything that is in the content source “Site” AND (the content is a publishing page OR the content is a document). If you need to know more about defining content sites, click here
The logic of these rules are as follows:
- Include = OR
- Require = AND
- Exclude = AND NOT
The ‘contentclass’ property specifies what type the indexed item is and will be automatically available for any content item in SharePoint. The two types that we are specifically targeting are:
- STS_ListItem_850 (Publishing Pages)
- STS_ListItem_DocumentLibrary (Documents)
SubsiteA
Title:
SubsiteA
Description:
Search scope specific to SubsiteA site & subsites
Rules
Behavior
Folder = http://SharePointSite.com/SubsiteA
Require
contentclass = STS_ListItem_850
Include
contentclass = STS_ListItem_DocumentLibrary
Include
ContentSource = Site
Require
Search Field Customisation
Determining which search scope is to be used is done programmatically. Search queries are inputted using a field on the master pages of the site rather than an independent control on the page or web part. This means that on the event where a user submits a search it will execute a search query against the Enterprise Search in Microsoft Office SharePoint Server 2007 service by encoding the query in a URL and posting it to the custom search page.
When doing this we are passing two parameters: http://SharepointSite.com/Utils/Pages/SearchSite.aspx?k=Keyword&s=SubsiteA
- K=”Keywords” – The keywords submitted by our user
- S=”Scope” – The scope which will be used to run our query against
Posting from master page
Before implementation of this solution, the search button event posted just the keyword to the search centre producing a site collection level search:
protected void ImageButtonSearch_Click(Object sender, ImageClickEventArgs e)
{
Page.Response.Redirect("/Utils/Pages/SearchSite.aspx?k=" + txt_Search.Text);
}http://SharePointSite.com/Utils/Pages/SearchSite.aspx?k=Keyword
This has been extended to:
protected void ImageButtonSearch_Click(Object sender, ImageClickEventArgs e)
{
SPSite site = new SPSite(Page.Request.Url.AbsoluteUri);
SPWeb web = site.OpenWeb();
string strSiteTitle = web.Title;
string strParentSite = web.ParentWeb.Title;if (strSiteTitle == "SubsiteA" || strParentSite == "SubsiteA")
{
Page.Response.Redirect("/Utils/Pages/SearchSite.aspx?k=" + txt_Search.Text + "&s=SubsiteA");
}else
{
Page.Response.Redirect("/Utils/Pages/SearchSite.aspx?k=" + txt_Search.Text);
}
}
This code utilises the Microsoft SharePoint 2007 development API first of all opening a connection to the current site. Once the connection is open the Site Title and the Parent Site Title are stored.
The code then checks if the Site Title or Parent Site Title matches the conditions that it is one of our site level search enabled sites. At which point it passes the extended url string to the search centre including which scope to use. In our case any searches within the upper level subsite area and all of its subsites are included. A more specific rule can be created by removing the parentsite condition.
NOTE: The name of the scope being used must be identical to the Title of the search scope and case sensitive. An invalid scope title passed into the query will return zero search results with no error.
Deployment
Presently the above code is deployed by being produced on each master page used by selected pages in the scope of this implementation. For future implementations it may be more appropriate to develop and install a custom SharePoint Feature which processes all search queries across the entire site. This would be viable on a larger scale implementation where by each site (every site) had predefined processes and search scope requirements.
The scope of this implementation is focused on the above pages and does not justify the design, development, deployment and testing requirements of implementing a site wide custom search handler feature although that would probably be the best way to do it.