Adding users to the default members group
-
I was wanting to build a web control that did a few things for admins of a site. One of the processes was to add a user to the default members group of the site along with some other security settings. This was to help admins do all of this on one page instead of going to each group individually to add a user. Here is the code I am currently using to accomplish this:
web.Groups("AR Test Site Members").AddUser(newStaff.User)
This work fine on my test site, but when I move it over to production that group name will change to the [Site Name] Site Members. I noticed that you could also used an index of the group instead of the name, so I used '5' because I noticed that was in the query strings for the address to look at the group members. When I used '5', I get an argument out of range error. How can I find the index number of this default group so that when I build the code I don't have to worry about finding out which site I'm on?
-
I was wanting to build a web control that did a few things for admins of a site. One of the processes was to add a user to the default members group of the site along with some other security settings. This was to help admins do all of this on one page instead of going to each group individually to add a user. Here is the code I am currently using to accomplish this:
web.Groups("AR Test Site Members").AddUser(newStaff.User)
This work fine on my test site, but when I move it over to production that group name will change to the [Site Name] Site Members. I noticed that you could also used an index of the group instead of the name, so I used '5' because I noticed that was in the query strings for the address to look at the group members. When I used '5', I get an argument out of range error. How can I find the index number of this default group so that when I build the code I don't have to worry about finding out which site I'm on?
Aptiva Dave wrote:
group name will change to the [Site Name] Site Members
go through each element of the site groups collection and look if the name contains "Site Members" (or ends with site members).
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
-
Aptiva Dave wrote:
group name will change to the [Site Name] Site Members
go through each element of the site groups collection and look if the name contains "Site Members" (or ends with site members).
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
Yes group name will appear with site name and Member group,visitors,owners
-
Yes group name will appear with site name and Member group,visitors,owners
It wasn't a question, that was the work the code should do.
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
-
It wasn't a question, that was the work the code should do.
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.
OK.But users who has Contribute permissions will be added directly to members group.
-
OK.But users who has Contribute permissions will be added directly to members group.
balaji1010 wrote:
OK.But users who has Contribute permissions will be added directly to members group.
Yes but the wasn't the question asked. The question was: How can he identify the "Site Members" group, when he don't know how the site is called.
------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.