Create groups programmatically in WSS 3.0


Here are some simple codes to do it:

1. Add the group (newMembersGroup)
2. Set the permissions of the group (role assignment) to contributor
3. Add the author to the group.
4. Associate the group to the site.
Dim groupOwner As SPUser = site.Author
site.SiteGroups.Add(newMembersGroup, groupOwner, Nothing, “”)

Dim membersGroup As SPGroup = site.SiteGroups(newMembersGroup)
membersGroup.OnlyAllowMembersViewMembership = False
membersGroup.AllowMembersEditMembership = False
membersGroup.AllowRequestToJoinLeave = True
membersGroup.AutoAcceptRequestToJoinLeave = True
membersGroup.Update()

Dim contributor As SPRoleDefinition = site.RoleDefinitions.GetByType(SPRoleType.Contributor)
Dim membersRoleAssignment As SPRoleAssignment = New SPRoleAssignment(CType(membersGroup, SPPrincipal))
membersRoleAssignment.RoleDefinitionBindings.Add(contributor)
site.RoleAssignments.Add(membersRoleAssignment)
‘Add the site author as a member
membersGroup.AddUser(site.Author)
membersGroup.Update()
site.AssociatedMemberGroup = membersGroup
site.Update()
More info in Role Assignments: http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.sproleassignment.aspx

More info to create your Group (now Cross Site Groups) : http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spgroupcollection_methods.aspx

Migration from MySQL to SQL Server 2005


Backup individual tables


There are few ways we can backup individual tables. Here are some of them:

  1. Use BCP or SSIS/DTS.
  2. 3rd party vendors do it like litespeed (http://www.quest.com/litespeed_for_sql_server/ ).  Litespeed on the backend is just really doing a BCP for the most part. They’ve just made it easier by putting a GUI
  3. Ditto for SQL BackTrack by BMC.

ASP.NET authentication using SQL 2005


There are conditions where we have our development environment on a SQL express (vs 2005) machine and we are trying to get the same code to run on a SQL Server 2005 machine. But, we cannot connect to the ASP.NET provider db even after registering a sql db in asp_net_regsql or something like that. By default, it uses whatever settings are in the machine.config file. So, that file usually has the settings that point to using a LocalSqlServer connection string, which is also defined in the machine.config as a user instance DB in the DataDirectory.

There are 2 ways to make it works:

  1. Removing the LocalSqlServer connection string and then adding one to your point to your DB in web.config. The connection strings section of your web.config file should look something like this:

    <connectionStrings>
    <remove name=”LocalSqlServer”/>
    <add name=”LocalSqlServer”
    connectionString=”Data Source=Server\Instance; Integrated Security=SSPI; Initial Catalog=database;”
    providerName=”System.Data.SqlClient”/>
    </connectionStrings>

  2. Provide your own <membership> section and specify the specific connection & provider type to use for membership.

    <configuration>
    <connectionStrings>
    <add name=”MySqlConnection” connectionString=”Data
    Source=MySqlServer;Initial Catalog=aspnetdb;Integrated
    Security=SSPI;” />
    </connectionStrings>
    <system.web>
    <membership defaultProvider=”SqlProvider” userIsOnlineTimeWindow=”15″>
    <providers>
    <clear />
    <add
    name=”SqlProvider”
    type=”System.Web.Security.SqlMembershipProvider”
    connectionStringName=”MySqlConnection”
    applicationName=”MyApplication”
    enablePasswordRetrieval=”false”
    enablePasswordReset=”true”
    requiresQuestionAndAnswer=”true”
    requiresUniqueEmail=”true”
    passwordFormat=”Hashed” />
    </providers>
    </membership>
    </system.web>
    </configuration>

* Thanks to Shawn Cicoria and George McKee for the solution.

Online collaboration for teamwork and project management


I got chance to work in different type of companies in my working life. Basically it can be categorized in to 2 types; either project base or product base. However, I found that most of the project or product development is not being managed well. You can see someone is doing nothing all the time and someone is busy like hell. Manager or top management never knows exactly what the progress is. We do not really have a system to manage, assign task to worker, and keep track the progress of each individual’s task. We always end up with sending, replying email in order to communicate, and sharing files among team members. It was really a terrible experience.

Online collaboration workspace for teamwork and project managementI had spent some of my free time to develop an online collaboration solution for teamwork and project management, ajaxworkspace.com. I know this cannot compare with other professional collaboration tools like groove or SharePoint since this only develop by me alone. However, I hope I can improve it to become better and better. Hopefully, it can be use by SOHO user, freelancer and small-mid size company. Here are some of the product features I get from ajaxworkspace.com

AJAX workspace offers a secure Web-based workplace consisting of an integrated suite of simple and easy to use collaboration application. You can efficiently organize yourself, manage projects and work with your entire enterprise, colleagues and team member from one central location. The ideal tool for any type of project management regardless if you are working in a company or if you are working as freelancer from home.

Read the rest of this entry »

Where is my book???


I bought a book “Pro WF: Windows Workflow in .NET 3.0 (Expert’s Voice in .Net)” from amazon early April. I suppose to receive it somewhere around 18-25 april, but don’t know why I still do not get it yet :( It cost me RM 150++! Nothing I can do now. Just keep waiting… Hopefully will get it soon…

How to install and deploy BSM 2005 into MOSS 2007


Business Scorecard Manager 2005 is not supported officially in MOSS 2007. Here are some work around to make it work.

To install BSM 2005:

  1. Make sure all prerequisite software like ADOMD.NET and msxml were installed.
  2. Run updateBSM.vbs update registry for SharePoint site. You need to run it again when creating a new site.
  3. Proceed to run server.msi and builder.msi

To deploy BSM 2005 to MOSS:

  1. In your MS Business Scorecard Builder IDE, proceed to deploy to SharePoint site as usal. The newly deployed page never work. We just want to deploy necessary web parts and it’s scorecard entry to SharePoint server.
  2. To view the Scorecard, add “Office Scorecard View” and “Office Report View” web part to your page. If you encounter error web part cannot desirable, make sure you add in the
    <add key=”Bpm.ConnectionString” value=”Integrated Security=SSPI;Initial Catalog=ScorecardServer; Data Source=(local)”/>
    in web.config under appsetting and change the data source accordingly.
  3. Once web part added, just modify the web part as usual to select your Scorecard and View.

70-542… Pass?


I just checked on my MCP portal and found I passed my beta exam for “70-542 TS: Microsoft Office SharePoint Server 2007 – Application Development”. Suprise for me!

I took 2 beta exams early January. I only able to pass one of it and failed on “70-541 TS: Microsoft Windows SharePoint Services 3.0 – Application Development”.  Don’t ask me why and how. Just try my best to shoot all the correct answers! :P

P/s: I guess if you dig around on MOSS for few months, you could pass it easily too! 

Adding item to sharepoint 2003 SPList Programmatically


I come accross some problems when adding new item to a SPList. The error i got is “Value does not fall within the expected range. ” This would only happen if you target list is empty. After do some googling, this seems is MS known bugs. Luckly there is workarround to solve this issue. Simple rules is

1. Add a new item, assign “Title” item and save it

2. Get the newly created item and update it with remaining items.

Here are the codes:

SPListItem newListItem = spList.Items.Add();

newListItem["Title"] = “The title”;

newListItem.Update();

SPListItem existingListItem = spList.GetItemByID(newListItem.ID);

existingListItem[2] = “Category 1″;

existingListItem.Update();

P/s: You only need to add new item as in this way for the empty SPList. Once u have at least one item.. the error will gone.

Please visit the original article: http://blog.buro9.com/2007/02/26/sharepoint-splistitem-quirks for more information…

MS SQL xp_cmdshell permission error


Do you ever get Access denied error when using MS SQL xp_cmdshell command?

E.g.  I have an special AD account access to \\server2\backups folder.  In my Store Procedure, I have to copy db.bak from local folder to share folder.

EXEC xp_cmdshell ‘copy c:\SQLbcks\db.bak \\server2\backups\db.bak, NO_OUTPUT’;

I get access denied error because xp_cmdshell use permission associate with SQL server service account (local system account). I have to change the SQL service account to use the AD account in order xp_cmdshell able to use the correct permission.  This seems a bit weired.  Do we have other solutions?