Creating Securtiy Groups Programmaticaly
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Creating Securtiy Groups Programmaticaly

 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development
Author Message
barre
Guest





Posted: Mon Oct 24, 2005 12:51 pm    Post subject: Creating Securtiy Groups Programmaticaly Reply with quote

Hi all,

I was given the assignment to implement a little program that is able
to read data from an XML file and then create area's and groups on the
portal site.

I'm having a problem with creating the groups. Wheneven I create a
group, the group is created. No problems so far, but when I want to
check it's permissions on the portal site, I get the following error.

"Object not set to an instance of an object".

Here is the code with wich I am creating the Groups :

SPSite site = new SPSite("http://MyURL");
SPWeb PortalWeb = site.OpenWeb();

SPRights Rights = new SPRights();
PortalWeb.AllowUnsafeUpdates = true;
PortalWeb.Roles.Add("NewGroup", "This is my new
group",PortalWeb.Roles["Administrator"].PermissionMask);
PortalWeb.Roles["NewGroup"].Update();

I realy hope someone can help me with this.

Greetz

Barre
Back to top
Gustavo
Guest





Posted: Mon Oct 24, 2005 12:51 pm    Post subject: RE: Creating Securtiy Groups Programmaticaly Reply with quote

Hi Greetz,
And if you try with

PortalWeb.Roles.Add("NewGroup", "This is my new
group", SPRights.FullMask);

instead of

PortalWeb.Roles.Add("NewGroup", "This is my new
group",PortalWeb.Roles["Administrator"].PermissionMask);

?
Saludes,
Gustavo
http://www.gavd.net/servers/default.aspx


"barre" wrote:

Quote:
Hi all,

I was given the assignment to implement a little program that is able
to read data from an XML file and then create area's and groups on the
portal site.

I'm having a problem with creating the groups. Wheneven I create a
group, the group is created. No problems so far, but when I want to
check it's permissions on the portal site, I get the following error.

"Object not set to an instance of an object".

Here is the code with wich I am creating the Groups :

SPSite site = new SPSite("http://MyURL");
SPWeb PortalWeb = site.OpenWeb();

SPRights Rights = new SPRights();
PortalWeb.AllowUnsafeUpdates = true;
PortalWeb.Roles.Add("NewGroup", "This is my new
group",PortalWeb.Roles["Administrator"].PermissionMask);
PortalWeb.Roles["NewGroup"].Update();

I realy hope someone can help me with this.

Greetz

Barre

Back to top
Gustavo
Guest





Posted: Mon Oct 24, 2005 4:51 pm    Post subject: Re: Creating Securtiy Groups Programmaticaly Reply with quote

Hi again,
Yes, I did it a couple of times. Something like:

SPWeb MySite = MySrv.Sites[currentUserProfile.PersonalUrl].OpenWeb();
//MySrv is the Virtual Server used for this site
//currentUserProfile is the current user, gived by his LoginName
//But you can a reference for MySite in different ways

//Make a new site
SPWeb MyPFSite = null;
MyPFSite = MySite.Webs.Add("Name", "Desc", "", 1033, "Template", true, false);

//Make a new role for the site
MyPFSite.Roles.Add("Owner", "Desc Owner", SPRights.ViewListItems |
SPRights.ViewPages | SPRights.BrowseUserInfo |
SPRights.AddListItems);

//Add an user to the rol
MyPFSite.Roles["Owner"].AddUser(CurUser.LoginName, CurUser.Email,
CurUser.Name, CurUser.Notes);
//CurUser is the current user, but it can be any user

And it works...
Saludes,
Gustavo
http://www.gavd.net/servers/default.aspx


"barre" wrote:

Quote:
Hi Gustavo,

thx for the reply !

I'v trie youre suggestion, but no luck. Have you done this before? If
so how did you do it?

greetz, Barre

Back to top
barre
Guest





Posted: Mon Oct 24, 2005 4:51 pm    Post subject: Re: Creating Securtiy Groups Programmaticaly Reply with quote

Hi Gustavo,

thx for the reply !

I'v trie youre suggestion, but no luck. Have you done this before? If
so how did you do it?

greetz, Barre
Back to top
barre
Guest





Posted: Mon Oct 24, 2005 4:51 pm    Post subject: Re: Creating Securtiy Groups Programmaticaly Reply with quote

Hey Gustavo,

I've tried you're suggestion, but no luck. Have you ever done what i'm
trying to do? If so, how did you do it?

Barre


Gustavo schreef:

Quote:
Hi Greetz,
And if you try with

PortalWeb.Roles.Add("NewGroup", "This is my new
group", SPRights.FullMask);

instead of

PortalWeb.Roles.Add("NewGroup", "This is my new
group",PortalWeb.Roles["Administrator"].PermissionMask);

?
Saludes,
Gustavo
http://www.gavd.net/servers/default.aspx


"barre" wrote:

Hi all,

I was given the assignment to implement a little program that is able
to read data from an XML file and then create area's and groups on the
portal site.

I'm having a problem with creating the groups. Wheneven I create a
group, the group is created. No problems so far, but when I want to
check it's permissions on the portal site, I get the following error.

"Object not set to an instance of an object".

Here is the code with wich I am creating the Groups :

SPSite site = new SPSite("http://MyURL");
SPWeb PortalWeb = site.OpenWeb();

SPRights Rights = new SPRights();
PortalWeb.AllowUnsafeUpdates = true;
PortalWeb.Roles.Add("NewGroup", "This is my new
group",PortalWeb.Roles["Administrator"].PermissionMask);
PortalWeb.Roles["NewGroup"].Update();

I realy hope someone can help me with this.

Greetz

Barre

Back to top
Barre
Guest





Posted: Tue Oct 25, 2005 4:51 pm    Post subject: Re: Creating Securtiy Groups Programmaticaly Reply with quote

Has anyone done this on portal level. I want to create a group on
portal level. not on area level. Or isn't there a difference?
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB