|
|
 Rank: Devotee
Joined: 10/16/2008 Posts: 64 Location: Spain
|
Hey, I'm trying to figure out how I can with one line find out if a specific user is member of a specific group. I have this code which works but I'd like to optimize it a bit. Code: string group = "MY GROUP"; Member m = Member.GetMemberFromLoginNameAndPassword(txtUserName.Text, txtPassword.Text); foreach (MemberGroup mg in m.Groups.Values) { if (mg.Text.ToLower().Equals(group)) { m = null; break; } }
Thanks Scott
Scott
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Scott, MemberGroup.HasMember(memberId) could be usefull in this case, but you'll need MemberGroup.GetbyName(name) as well Both methods available in MemberGroup class which resides in umbraco.cms.businesslogic.member namespace Hope this helps. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Devotee
Joined: 10/16/2008 Posts: 64 Location: Spain
|
I have been trying to get the MemberGroup.HasMember however it does not exist in my businesslogic namespace.
Could you post an example of how to do this?
Thanks
Scott
Scott
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Nope, scott, don't have a working example (Currently at the client's office). It should live in the cms assembly (umbraco.cms project if you have the code floating somewhere; Namespaces/assemblies are a bit confusing at times...) Greetz, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Devotee
Joined: 10/16/2008 Posts: 64 Location: Spain
|
Could you when you get back please let me know if you can find/make a working example because I don't seem to be able to figure it out.
Thanks
Scott
Scott
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Scott, Got some working example. It is just sample code, but works as expected. Contact me through e-mail and I'll send some of the code and a sample setup for testing. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi Scott, Did you receive my e-mail? Greetz, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Devotee
Joined: 10/16/2008 Posts: 64 Location: Spain
|
Hey Dirk,
Thanks I did - I haven't had the time to look at it yet though I have had plenty of things to take care of today. Well a peek - could not help it. I found a quite simple line MemberGroup.GetByname(group).HasMember(m.Id) which checks it. I haven't tested it fully yet though.
I will look more into it tomorrow..
Again thank you very much Dirk.!
Scott
Scott
|
|
|
Guest |