How to get the SP User ‘Owner” object of the site

Objective was create the custom group,and while creating custom group we need to specify the owner of the group,So we accessed the SPUser object of the owner in this way.This is the best way as there is no need of specifying any hard coded values.

SPUser owner =null;
owner = subSite.SiteGroups.GetByID(int.Parse(subSite.Properties["vti_associateownergroup"]));

Similarly Members group and visitor group can be accessed
SPUser member =null;
owner = subSite.SiteGroups.GetByID(int.Parse(subSite.Properties["vti_associatemembersgroup"]));

SPUser visitor =null;
owner = subSite.SiteGroups.GetByID(int.Parse(subSite.Properties["vti_associatevisitorgroup"]));

Advertisement

~ by Saurabh Mittal on August 24, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.