Thursday, January 15

Creating Custom User Groups in SharePoint

Steps:

1)Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

2)Create a new folder named ‘CustomGroup’

3)Copy Feature.xml from any other folder in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

4)Write following code in Feature.xml file



Notice the ResourceAssembly and ReceiverClass attributes. These serve as references to the assembly that will handle the FeatureActivated, FeatureDeactivating, FeatureInstalled and FeatureUninstalling events.

5) create the SPFeatureReceiver class referenced above by following steps:

a) Open Visual Studio

b) New project then choose Class library

c) Name it as CustomGroupFeature

d) Add reference Microsoft.SharePoint

e) Copy the code given below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace CustomGroupFeature
{
class FeatureReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//get a reference to the site collection where the feature is activated
using (SPSite site = properties.Feature.Parent as SPSite)
{
//get a reference to the root site / web of the site collection
using (SPWeb web = site.RootWeb)
{
//get a reference to a Site Owner
//(there should always be at least 1; position 0 of the
//Administrators UserCollection)
//we'll make this user the owner of the custom group
SPMember siteOwner = web.SiteAdministrators[0];

//prepare the group name
string grpName = "Custom Group";

//check if group exists
bool grpExists = false;

//-----------------------------------------------------
//THIS CODE SHOULD BE MOVED TO ITS OWN HELPER FUNCTION
//OR UTILITIES CLASS. IN FACT MOST OF THIS CODE NEEDS
//TO BE REFACTORED
foreach (SPGroup group in web.SiteGroups)
if (group.Name.ToLower() == grpName.ToLower())
grpExists = true;
//------------------------------------------------------

//add the custom group to the site
//if it doesnt allready exist
if (!grpExists)
{
web.SiteGroups.Add(grpName, siteOwner, null,
"Custom Group that I created because I can!");
web.Update();

//get a reference to the group we just created
SPGroup customGroup = web.SiteGroups[grpName];

//add the group to the quicklaunch
web.Properties["vti_associategroups"] =
web.Properties["vti_associategroups"] + ";"
+ customGroup.ID.ToString();
web.Properties.Update();
}
}
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
//throw new NotImplementedException();
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
//throw new NotImplementedException();
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
//throw new NotImplementedException();
}

//.....FeatureDeactivating, FeatureInstalled, and FeatureUninstalling methods
}

}

f) Create strong name

g) Build it

6) Add the dll to Assembly

7) Get the public key tocken

8) Update in Feature.xml

9) Open command prompt

10) Go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

11) Install the feature using:

stsadm.exe –o installfeature –filename CustomGroup \feature.xml –force

12) Open SharePoint site

13) Go to Site settings then Site Collection features

14) Now CustomUserGroup is available.

15) Activate this feature.

16) Now if the SharePoint site is opened, then CustomUsergroup is available.

6 comments:

Anonymous said...

On the left side of the device, sexcam so the threat of constantly hitting them is
noticeably alleviated. Separate phone apps can't be run in their own windows, and while it was fine for quick snaps, it wasn't blowing the doors off the joint.

Anonymous said...

18 scRnd 9: Sc in each sc around, join, ch 1, 2 dc in space
or stitch sexcam indicated three loops on hook.
Huff Post bloggers are stepping back to look
at the bigger picture, showing that even when things aren't going your way, and the code then helps others from making the same mistakes from happening again.

my site ... sexcams

Anonymous said...

Your style is really unique compared to other people I've read stuff from. Thanks for posting when you've got the opportunity,
Guess I'll just book mark this web site.

My web blog - property

Anonymous said...

These are just fleshlight
a part of the Rust Belt's rise and fall.

Anonymous said...

Wenn ԁu daѕ mit Νein beаntworten kаnnst, dann wird es für dich jeԁoch
Zeit. ӏch liebe es, ωenn ich mich аuf diеsen Mann einlaѕsen
und er mich bumsen könnte. Wolltest ԁu schon іmmer
eіnmаl ein Sexκontaκte mit einеr Frau haben, die diг im Βеtt noch einiges bеibringеn kann.


Wіllst ԁu diг meine Web Seіte anѕehen?

sexkontakte österreich

Anonymous said...


http://www.petinsuranceuks.co.uk This is useful to be included in your standard health care managing strategy to deal with severe scenarios. But birds, reptiles, guinea pigs, rabbits, rats, ferrets, chinchillas, hamsters, gerbils and other pocket pets can be covered indefinitely from the age of six weeks.