Tuesday, July 17, 2012

Verify user credentials

If you would need to verify user's windows credentials you can use this code:
            // create a "principal context" - e.g. your domain (could be machine, too)
            using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "DOMAIN"))
            {
                // validate the credentials
                bool isValid = pc.ValidateCredentials(@"user", "password");

                if (isValid == true)
                    return "user is valid";
                else
                    return "user is not valid";
            }

Thursday, July 12, 2012

Related content link doesn't work in InfoPath

Recently I needed to customize task's InfoPath form. Everything went well except that the related link which normally leads you to related item of your task didn't work. After short investigation of this problem I found out that the URL address contains spaces. This was caused by titles of the sites (if site title contains spaces, this spaces are then used in URL).
All you have to do is to create a new field (Hypertext Link) in the SharePoint designer and then in properties of this field set the Default value. Default value is then function like this:
concat(substring-before(Related Content; " "); "%20"; substring-after(Related Content; " "))


Hope this could help somebody :)

How to set URL of the site logo link

Hi everyone :)
I am not much of expert when it comes to SharePoint branding, but recently I needed to solve simple task and because I don't want to forget it I will paste it here :)
Requirements were very simple - SharePoint mastePage has site logo which is usually link to somewhere. You can change this URL in SPDesigner and manually write URL like this "http://www.mySharePointServer.com/", but I wouldn't recommended this approach 'cause if you have at least testing server you would have to change it there to and who wants to remember a lot of stuffs to change after you migrate your master page into different environment :)
So I found this two common variations which you can use to satisfy your requirements (As I wrote before I am not much of expert so there must be more methods to create generated URL and if you know some of them please do not hesitate to comment it. I would be glad to read it).

Link to the root site of the site collection:

<SharePoint:SPLinkButton runat="server" NavigateUrl="~sitecollection/" id="onetidProjectPropertyTitleGraphic">
<SharePoint:SiteLogoImage name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl=" ~sitecollection/ /PublishingImages/Logo.jpg" runat="server"/>
</SharePoint:SPLinkButton>


Link just to the top of the current site:

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitleGraphic">
<SharePoint:SiteLogoImage name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl=" ~sitecollection/ /PublishingImages/Logo.jpg" runat="server"/>
</SharePoint:SPLinkButton>

Wednesday, July 11, 2012

Windows SharePoint Services Web Services

Sometimes your requirements need to create web services to do something inside SharePoint. Before you start to write your own custom code you can check this site to review if the action you require is not already there http://msdn.microsoft.com/en-us/library/ms479390(v=office.12).aspx