Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting User group Names

2 views
Skip to first unread message

Zee

unread,
Jun 21, 2005, 10:41:02 AM6/21/05
to
Dear All,

I have created a custom group in WSS. I have assigned users to the
group.
I am programming a web part and need to know the groups (or the
specific group) the user belongs to.
My entire search has yielded to Page.User.Identity.Name.ToString(),
which obviously goes not give the group names.
Has any one been able to get the group names? I presume this is a
basic need and there will be a way to get at this. If so, please give a hint
or a code snippet.

Thanks,

Zee


Gustavo

unread,
Jun 21, 2005, 11:55:03 AM6/21/05
to
Hi Zee,
The SPUser Class have a Groups property (of SPGroupCollection type) and a
Roles property (of SPRoleCollection type) for this purpose.
Saludes,
Gustavo
http://www.gavd.net/servers/default.aspx

Zee

unread,
Jun 21, 2005, 12:39:05 PM6/21/05
to
Thanks for the response.
I am bit new. Can you ps give a code snippet that can kick start
my development. I looked at Microsoft MSDN pages of the classes. Well that
not very clear. FYI, I am using WSS.

Zee

Gustavo

unread,
Jun 22, 2005, 2:24:01 AM6/22/05
to
Hi Zee,
Something as:

SPUser user = web.CurrentUser; //of another user
SPRoleCollection roleColl = user.Roles;
SPGroupCollection groupColl = user.Groups;

foreach (SPRole role in roleColl)
{
role.Name; //do something with role
}

foreach (SPGroup group in groupColl)
{
group.Name; //do something with group
}

Saludes

Zee

unread,
Jun 22, 2005, 11:44:02 AM6/22/05
to
Thanks again, this is great. I am almost there.

I am using WSS & writing this as a web part. When I use
SPWeb web = SPControl.GetContextWeb(Context);
SPUser user = web.CurrentUser;
and check on debug mode on VS.NET, the object web cant get a value
for CurrentUser instead its shown as
"CurrentUser <error: an exception of type:
{System.Security.SecurityException} occurred> Microsoft.SharePoint.SPUser"

Any ideas on solving this security exeption? Arent the
Microsoft.Sharepoint.***
trusted???

Thanks

Gustavo

unread,
Jun 23, 2005, 4:00:06 AM6/23/05
to
Hi Zee,
You are having a authentication problem. Try to low the trust level in your
web.config to "Full", maybe can it help.
Saludos,

Zee

unread,
Jun 24, 2005, 4:09:09 AM6/24/05
to
This is great. I am there.
Thanks a lot for your help.

Nikander and Margriet Bruggeman

unread,
Jun 28, 2005, 8:42:07 AM6/28/05
to
Hello,

You probably don't wanna hear this right now, but do you want to go in production
using full trust mode? You would be better of analyzing what security permission
you're security policy file is missing and add this to the policy file. And
what do you mean exactly when you say Microsoft.SharePoint.* assemblies are
trusted? Some SharePoint assemblies are registered by default as safe controls
so certain web parts can be used. This doesn't mean that custom code can
use every aspect of the SharePoint object model, this behavior is determined
by the security policy file configured in de <trust> level element of the
web.config file.

Kind regards,
Nikander & Margriet Bruggeman

sagar

unread,
Oct 28, 2009, 2:50:53 AM10/28/09
to

help

how can display all user details information information in wss3.0 i m
waiting Ur +ve response

url:http://www.ureader.com/msg/1233463.aspx

0 new messages