Tuesday 1 December 2009

Remove Inactive Accounts from MOSS

A common problem which we regularly encounter in MOSS Intra-Net websites. "Importing the profiles from Corporate Active Directory". As the people move in and out, the active directory will be updated and modified continuously so as MOSS Profiles. And when we search for the people using MOSS search, it looks awkward if we are still showing inactive accounts ie, details of the people who have moved out of our organisations. So in order to get the active users from LDAP, we need to configure the following filter

(&(objectCategory=person)(objectClass=user)( !(userAccountControl:1.2.840.113556.1.4.803:=2)))

Steps for this:
1) Log into Central Administration --Shared Services Provider Application.

2) Click on Userprofiles and properties.

3) Click on View Import Connections to edit them (http://[SharedServices:Port]/ssp/admin/_layouts/EditDSServer.aspx?dn=xxxx)

4) Locate user Filter text field and then enter the following line:
(&(objectCategory=person)(objectClass=user)( !(userAccountControl:1.2.840.113556.1.4.803:=2)))

Now let us see what is the userAccountControl


userAccountControl:1.2.840.113556.1.4.803 specifies the user control to be queried against LDAP objects to get the field values which has value of 2 (bit value)-- means Disabled Accounts. As we are specifying ! (not) before, means Do not get the Inactive accounts.
Ampersand & before the variables means we are joining the different conditions with AND clause.
To specify more UserAccountControl values, refer this Link : http://msdn.microsoft.com/en-us/library/aa772300(VS.85).aspx;

5)Click on Start Full Import

6)As we have included the filter for not importing Inactive Accounts, we can see the total count of Inactive profiles and Active Profiles in http://[SSP:Port]/ssp/admin/_layouts/ProfMngr.aspx?ConsoleView=Active

7) Select the Inactive Profiles in the drop down and then select all of them (if they are any), and delete them from that View.(or doing a full import 3 times would delete inactive profiles)

8)Try to import again and see that this time no Inactive profiles are shown.

9)we can even delete these profiles from MOSS databases, but I would prefer to comply with MOSS strict recommendation of NOT TOUCHING DB.

10)After confirming the profiles, navigate to search administration in SSP

11)Timer jobs would have quick synchronisation jobs running to sync the profile details to portal.

12)Reset the crawled content and perform a full search.

I will add more for specifying more attributes to this LDAP filter. As the requirements are unique for each corporate.


Adding more attributes is more interesting thing for this LDAP Filters.
1) (&(K1)(K2)(K3)) -- this means join the conditions in brackets with AND operator
2) (|(K1)(K2)(K3)) --- obviously joining with OR operator.
3) Now the combination of them
(|(&(K1)(K2)(K3))(&(K4)(K5)))
means (K1 AND K2 AND K3) OR (K4 AND K5)

More information on this is available at MSDN Location

Details of available LDAP Attributes

Tuesday 20 October 2009

Sharepoint 2010

So finally the information of SHAREPOINT -2010 is getting unveiled.
Some of my tutors and friends started to update their blogs with this.
Refer :

Manish Speaks out about 2010


MSDN :

Begin with me


Exciting things to enjoy

Moving to Anumanchipalli
Cheers!
Happy SPD'ing

Tuesday 8 September 2009

Content Editor Web Part Tricks

1)Apply the styles dynamically using Content Editor Web part

I got a requirement, which needs to update the style dynamically on the page load for a specific tool bar item in the LIVE environment.
As the time we have is very limited, I thought of using java script to apply the required style.

Steps to achieve this

1. Added the Content Editor Web Part to the page
2. Added the following script
<script type = "text/javascript">
window.onload=function()
{
document.getElementById('[Id of tool bar Item]').style.background = "#BADDAD";
}

</script >
3. Content Editor web part is hidden.

Cheers we are done!.

*****************************************************************************************


2) Create a Upload Multiple Files Control using CEWP

Refer this for using Content Editor Web part for uploading Multiple Documents into your desired library

*****************************************************************************************



3)Display your outlook emails using CEWP
With the following script you can access the Outlook Inbox from Content Editor Web part

1) Add Content Editor Web part to the page
2) Add the following code into the webpart

<object classid="clsid:0006F063-0000-0000-C000-000000000046"
id="ViewCtlFolder" width="100%" height="200"
codetype="application/x-oleobject"
codebase="http://activex.microsoft.com/activex/controls/office/outlctlx.CAB#ver...">
<param name="Namespace" value="MAPI">
<param name="Folder" value="Inbox">//(you can replace this Inbox value with your required folder in Outlook box)
<param name="Restriction" value="">
<param name="DeferUpdate" value="0">
</object>

3) Click OK to see your outlook mails getting displayed in your page.
This needs outlook to be available on the box,where this page is being viewed.

*****************************************************************************************



4) Display the Flash files in Sharepoint Pages

1) Upload the desired Flash File to the Image Library and ensure that its approved

2) Add the Content Editor Web part to the required page in Portal.

3) Click on the webpart menu to open the tool part and click on "Source Editor"

4) Paste the following code
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="320" HEIGHT="240" id="Yourfilename" ALIGN="">
<PARAM NAME=movie VALUE="FLASHFILENAMEWITHPATH.swf">
<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333399>
<EMBED src="FLASHFILENAMEWITHPATH.swf" quality=high bgcolor=#333399 WIDTH="320" HEIGHT="240" NAME="Yourfilename"
ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>

5) Fill the values of "FLASHFILENAMEWITHPATH.swf" with your flash file path from step 1.

6) Click on "OK"

Then the flash file would be displayed.


*****************************************************************************************





Happy SPD'ing

Friday 3 July 2009

Create custom reports using Site Content and Structure

I got a cute requirement from my content team manager, asking to find out a simple way to find out the pages Approved,Rejected,Pending,Draft,scheduled to any one in the team.
After doing some research on existing reports provided by MOSS--"Manage Content and Site Structure", I thought we can do some thing over there.
Finally I deduced a way to add the new report to existing reports.
Steps are as follows:
1) Locate "Content and Structure Reports" list.
2) Add a new item for that list
3) Enter the following values in the new form displayed
Title = "All Documents(Aspx)"
CAML Query = "<Where><Eq><FieldRef Name='DocIcon' /><Value Type='Computed'>aspx</Value></Eq></Where>"

4) Now Navigate to "Site Actions-->Manage Content Structure"
5) Select View on the top toolbar and select "All Documents(Aspx)" from drop down.
Then the view would be displayed with all the pages in the portal.
Total number of results can be modified by choosing relevant number on the tool bar.

If we want to show only pages only with
a) Approved
Query: <Where><Eq><FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"></FieldRef><Value Type="Number">0</Value></Eq></Where>
b) Rejected
Query: <Where><Eq><FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"></FieldRef><Value Type="Number">1 </Value></Eq></Where>
c) Pending
Query: <Where><Eq><FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"></FieldRef><Value Type="Number">2</Value></Eq></Where>
d) Draft
Query: <Where><Eq><FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"></FieldRef><Value Type="Number">3</Value></Eq></Where>
e) Scheduled
Query: <Where><Eq><FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"></FieldRef><Value Type="Number">4</Value></Eq></Where>


Cheers!We are done
Happy SPD'ing

Saturday 27 June 2009

Host EXE files in MOSS

I got a typical requirement from my product manager. They are planning to host some of the MSI Installers and executables inside our current internet facing MOSS portal. As we are aware MOSS doesnt entertain EXE's, Even though we can remove them from exception list from Central Admin and can host them, it makes a vulnerable security leak in portal. As the site is Internet facing, virus infected EXE's can be uploaded into portal in that exception. So after some research I found a way where we can host the EXE's files in the MOSS.


1) Create a folder in the shared location on the web server (should be repeated on all Front end servers)
2) Provide the web-sharing for that folder and add an alias name for that by selecting the Relevant Sharepoint Web Application in the web-sharing properties tab
3) Add every one to that folder from security tab with "READ" access only
4) Open IIS and browse this newly created folder properties and ensure that "Anonymous access" is enabled.
5) Add the link as follows in any content enabled pages
Download your executable from here: "<a href = "[servername]/[websharedfoldername]/[exename]">"EXEName" </a>

Cheers!! we are done
Happy SPD'ing

Saturday 9 May 2009

Content Editor WebPart to Upload Multiple Documents to SharePoint Library

Today I got a cute requirement from my client manager to upload a huge bunch of documents to sharepoint library, for which they are unable to get "Multiple Upload" feature.
Then as an immediate resolution I have added an content Editor Web Part and added this piece of code chunks into that.
In this we are using the existing Upload file which can be found at 12 hive\Layouts.

<SCRIPT LANGUAGE="javascript">

function FilesUpload()
{
document.getElementById('idUploadCtl').MultipleUpload();
alert('File Uploading Completed');
}
</SCRIPT>

<INPUT TYPE="hidden" NAME="Cmd" VALUE="Save">
<INPUT TYPE="hidden" NAME="NextUsing" VALUE="http://[Server]/[Document Library]/Forms/AllItems.aspx">
<INPUT TYPE="hidden" VALUE="New">
<INPUT TYPE="hidden" NAME="putopts" VALUE="true">
<INPUT TYPE="hidden" NAME="destination" VALUE="http://[Server]/[Document Library]">
<INPUT TYPE="hidden" NAME="Confirmation-URL" VALUE="http://[Server]/[Document Library]/Forms/AllItems.aspx">
<INPUT TYPE="hidden" NAME="PostURL" VALUE="http://[Server]/_vti_bin/shtml.dll/_layouts/UpLoad.aspx" />
<INPUT TYPE="hidden" NAME="VTI-GROUP" VALUE="0">

<DIV ID='MukiDidAgain' >
<P CLASS="ms-toolbar">
<A HREF="javascript:FilesUpload()"
TARGET="_self">Save Files</A>
</P>
<OBJECT id=idUploadCtl name=idUploadCtl CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813 WIDTH='100%' HEIGHT='350px'></OBJECT>
</DIV>

! Replace [Server] with your server URL and [Document Library] with the desired document library



Cheers! we are done
Happy SPD'ing.

Wednesday 11 February 2009

MOSS Developer handy dandy tips

The most common tips which a MOSS Developer may need :
1)Access STSADM from any directory while in command prompt.
  • Start -> All Programs -> Control Panel -> Advanced-->System
  • Click the Environment Variables -->variable Path -->Edit button.
  • ;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
  • Click OK. Dont forget ; before the variable path.
  • ******************************************************************************
    2) Recyle the Application Pool with command prompt.
  • Open the command prompt and then type in following line.
  • %windir%\system32\cscript.exe c:\windows\system32\iisapp.vbs /a "[Name of your App Pool]" /r.
  • In placeholder of Name --write your application pool which you wish to recycle.
  • There is also a small custom tool which would do this.http://www.harbar.net/apm/apm2.zip.
    ******************************************************************************
    3) Grab the Public Key Token while in Visual Studio Environment.
  • In Visual Studio 2005, click Tools -> External Tools...
  • Click Add and enter the following into the different fields as displayed in the following
  • Title: Grab Public Key value
    Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
    Arguments: -Tp "$(TargetPath)"
    Check Output window option.
    Now when we have a signed project, and after building that project, just click on the Tools-->Grab Public Key value button, then we can see that value in the output window.
    ******************************************************************************
    4)Display all the Search Results before applying our custom XSLT/Styling
    a) Open the Search Results Page in Edit Mode.
    b) Click on "Modify Shared WebPart" link on "Search Core Results" web part.
    c) Click on XSL Editor button and in the Opened Editor window paste the following code.
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/">
    <xmp>
    <xsl:copy-of select="*"/>
    </xmp>
    </xsl:template>
    </xsl:stylesheet>

    d) Click OK and then refresh the page with search key word again then we can see the full results without any styling or customizations.
    ******************************************************************************
    5)Search for specific command in STSADM list at command prompt
  • We all often have seen when we type STSADM at its command prompt would show the huge list of its commands including the custom commands if we have any. It would be tiresome if we wanna run through the entire list to choose only one command which we forget that complete semantic.
  • For example if we want to create a site using STSADM then we can type in
    stsadm -help createsite. This shows the command with parameters.
    But if we want to rename the site then it would be tough for us trying to remember the correct operation Name.
  • But there is a way in which we can find all the relevant commands with keyword "site".
    Simply type in STSADM FIND "SITE" (with quotes, STSADM and Find are seperated using pipe symbol ) at the command prompt. It lists out all the commands which has word "site" in them.
  • Then pick your required command from them.

  • Check this link for all STSADM Commands and their purpose.


  • ******************************************************************************
    6) Export the (My)sites list to end user with less effort.
  • Recently I had a request from one of my client where they want to see all the MYSites of their corpnet users and their storage limits/details in XML format.
  • As usual STSADM came to my rescue with its wonderful command "enumsites".
    Just type in STSADM -o enumsites -url http://moss:xxxxx >>c:\MySitesList.xml
    And you are done. When the Operation is completed, then simply open C:\MySitesList.xml file for the details.

    ******************************************************************************


    7)Display Time at your Command prompt

    While executing the one of the STSADM commands, I found it took long time, but how much. We cant always look at the system time or your watch before executing command. I felt there should be some way in command window itself to show the command execution time.
  • Then after a small research, I found we can get the command executed time. Steps are following..
  • Open command prompt. Type in PROMPT $T $_ $P . And click enter.
  • Then the command prompt shows time before each command. Now we can find the total time of execution.

  • ******************************************************************************


    8) To Open Central Admin from command prompt

  • Make sure that "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\" is entered into environment variables as I mentioned earlier.
  • Then open command prompt type in psconfigui.exe -cmd showcentraladmin.
  • It opens the Central Admin quickly.

  • ******************************************************************************


    9) To perform mass publishing for documents/Images

  • Once the files are uploaded and every file is checked out, then go to that Library settings
  • Click on Versioning settings
  • Click on 'NO' for content Approval and click OK

  • Select Site Actions--Manage Content and Structure

  • And select the library and the items of the library would be displayed on the right pane. Select all of them and right click to find option "Publish".

  • It will do the trick. Once you are done then turn back Content Approval on

  • Even though this not a best practice, some times it help us

  • ******************************************************************************


    10) Saving output of STSADM command
    To save the output of STSADM Command into a text file use the following :
    eg:stsadm -o addsolution -filename MySoln.wsp >>output.txt 2>&1
    (Dont remove 2>&1--these are standard dos error handlers.)
    If we are using -immediate or -time or -local (Asynchronous commands) with STSADM command, then next STSADM command would fail. Like:
    stsadm -o retractsolution -name Mysolution.wsp -immediate
    stsadm -o deletesolution -name Mysolution.wsp
    The second command should execute after the first command has executed completely. But here it would fail.In order to avoid that we have two solutions
    Solution One:

  • echo some text pause

  • Solution Two:
  • Execadmsvcjobs command.But this should be used very carefully because it would execute all the administrative jobs immediately

  • ******************************************************************************



    11) Opening the Multiple Upload Window

    Sometimes, I have seen in the client environment, "MultipleUpload" link is not shown in document libraries,which we will discuss later, but as a simple trick to enable that, try to do following

    1. Open the document Library for which they cannot see "MultipleUpload"
    2. Click on "UploadDocument" and the window opens with URL /_layouts/Upload.aspx?=[ListID and some blah blah]
    3. Now add the "&MultipleUpload=1" at the end of the URL and press enter.

    It would open the MultipleUpload screen, still if you are unable to see "MultipleUpload", then refer the "Content Editor Web Part tricks" in Interesting Links.

    ******************************************************************************





    Happy SPD'ing

    Tuesday 27 January 2009

    Steps to Create a Alert WebControl and deploy to MOSS

    After many days I got an opportunity to create a webcontrol which creates the Alerts for the Logged in user. As my client insisted that they dont want to strain users by navigating inside the Sharepoint application page to create a alert, they want to create an alert with a single mouse click.


    Steps involved in creating a webcontrol:
    1) Create a button control,intialize it on the Page load, Assign the click event to that
    And attach code for that event handler.

    Code goes like this.


    namespace AlertMeWC
    {

    [ToolboxData("<{0}:ManageAlerts runat=server>")]
    public class ManageAlerts : WebControl
    {


    private System.String btnCreateAlert;
    private LinkButton btnCreate;

    public System.String btnCreateAlertID
    {
    get
    {
    return btnCreateAlert;
    }
    set
    {
    btnCreateAlert = value;
    }
    }

    private void CreateAlert(object sender, EventArgs e)
    {

    try
    {
    SPSecurity.RunWithElevatedPrivileges(delegate(){

    SPSite _site = SPContext.Current.Site;
    SPWeb _web = _site.OpenWeb();
    SPAlert newalert = _web.Alerts.Add();
    newalert.AlertType = SPAlertType.Item;
    newalert.AlertFrequency = SPAlertFrequency.Immediate;
    newalert.DynamicRecipient = Get the Logged in user details.

    if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/pages"))
    {
    newalert.Item = _web.GetListItem(HttpContext.Current.Request.Url.ToString()); newalert.Title = "Pages: FirstPage.aspx";
    newalert.Update();
    _web.AllowUnsafeUpdates = true;
    _web.Update();
    _web.AllowUnsafeUpdates = false;
    }
    });
    }
    catch (Exception ex)
    {
    Page.Response.Write("Error in ManageAlerts " + ex.Message.ToString());
    }
    finally
    {
    //Dispose web
    }
    }

    private void InitializeControls()
    {
    btnCreate = InitializeControls("btnCreateAlert", btnCreateAlert);
    }

    private T InitializeControls(string strPropertyName, string strControlID)
    {
    object _BaseControl = null;
    T _Return = default(T);

    if (String.IsNullOrEmpty(strControlID))
    {
    throw new ApplicationException("ManageAlerts Initialization failed: The " + strPropertyName + " attribute must specify a valid " + typeof(T).ToString() + ". The attribute was not specified.");
    }

    _BaseControl = this.NamingContainer.FindControl(strControlID);

    if (_BaseControl == null)
    {
    throw new ApplicationException("ManageAlerts Initialization failed: The " + strPropertyName + " attribute must specify a valid " + typeof(T).ToString() + ". The control " + strControlID + " cannot be found.");
    }

    if (!(_BaseControl is T))
    {
    throw new ApplicationException("ManageAlerts Initialization failed: The " + strPropertyName + " attribute must specify a valid " + typeof(T).ToString() + ". The control " + strControlID + " is a " + _BaseControl.GetType().ToString() + ", and is not supported.");
    }

    _Return =(T)_BaseControl;
    Return _Return;
    }

    protected override void OnLoad(EventArgs e)
    {

    base.OnLoad(e);
    try
    {
    InitializeControls();

    btnCreate.Click += new EventHandler(this.CreateAlert);

    }
    catch (Exception ex)
    {
    Page.Response.Write("Error: " + ex.Message.ToString());
    }
    finally
    {
    }

    }


    }
    }


    2)Assign the strong name, GAC and grab public key token.
    3)Navigate to your site where we would like to stick this webcontrol on.
    4)Create a new page and edit that page in Sharepoint designer.
    Add the following lines to that Page in SPD.
    <@ Register Tagprefix="muki" Namespace="AlertMeWC" Assembly="AlertmeWC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=#$@$%@$%@#%@5" %>
    Add this in body tag.
    <muki:ManageAlerts ID="ManageAlerts" runat="server" btnCreateReportID ="btnCreate"/>

    When ever the user clicks on this link, then automatically alerts are created
    Enjoy SPD'ing!!