Friday, March 16, 2012

Member of group?

Hello,
I am working with Visual Basic ASP.NET and creating web forms. I am trying
to write a function where I can input a username and groupname, and the
function will tell me whether that user is a member of that group or not?
However, I am having trouble figuring out how to do this. Can someone help?
Thanks,
Dusty HackneyI believe this to be nontrivial in .NET 1.x, but in .NET 2.0 it's a
joke...
Here's my C# 2.0 code...
StringCollection roles = new StringCollection( );
foreach (IdentityReference reference in WindowsIdentity.GetCurrent(
).Groups) {
string role =
((NTAccount)reference.Translate(typeof(NTAccount))).Value;
roles.Add(role);
}
roles is now the string collection of role names...
----
David Betz
http://www.davidbetz.net/dynamicbliss/
http://www.davidbetz.net/winfx/
Wow asp.net 2.0 has made life easier:)
Patrick
<agapeton@.gmail.com> wrote in message
news:1133889575.526596.83980@.f14g2000cwb.googlegroups.com...
> I believe this to be nontrivial in .NET 1.x, but in .NET 2.0 it's a
> joke...
> Here's my C# 2.0 code...
> StringCollection roles = new StringCollection( );
> foreach (IdentityReference reference in WindowsIdentity.GetCurrent(
> ).Groups) {
> string role =
> ((NTAccount)reference.Translate(typeof(NTAccount))).Value;
> roles.Add(role);
> }
> roles is now the string collection of role names...
> ----
> David Betz
> http://www.davidbetz.net/dynamicbliss/
> http://www.davidbetz.net/winfx/
>
Thanks for the response. Is there a way to feed the program a different
username (without providing the password) instead of having it use the
currently logged in user?
"agapeton@.gmail.com" wrote:

> I believe this to be nontrivial in .NET 1.x, but in .NET 2.0 it's a
> joke...
> Here's my C# 2.0 code...
> StringCollection roles = new StringCollection( );
> foreach (IdentityReference reference in WindowsIdentity.GetCurrent(
> ).Groups) {
> string role =
> ((NTAccount)reference.Translate(typeof(NTAccount))).Value;
> roles.Add(role);
> }
> roles is now the string collection of role names...
> ----
> David Betz
> http://www.davidbetz.net/dynamicbliss/
> http://www.davidbetz.net/winfx/
>
I need to do this exact same function. I need to provide a username and chec
k
their group memberships. Did you ever get a good resolution to this issue?
Thanks!
--
Jaret Langston
Amsouth Bank
"Dusty Hackney" wrote:
> Thanks for the response. Is there a way to feed the program a different
> username (without providing the password) instead of having it use the
> currently logged in user?
>
> "agapeton@.gmail.com" wrote:
>
No. I am using VB and .NET 1.x. So far, I haven't figured out how to
accomplish seeing if a user is a member of a group by providing a function a
username and a group name (but no password).
"Jaret Langston" wrote:
> I need to do this exact same function. I need to provide a username and ch
eck
> their group memberships. Did you ever get a good resolution to this issue?
> Thanks!
> --
> Jaret Langston
> Amsouth Bank
>
> "Dusty Hackney" wrote:
>
Dusty if you are interested in a Domain environment and you re interested in
aRoles based Auth
See my blog at :-http://spaces.msn.com/naijacoder/
Hope that
helps
PAtrick
"Dusty Hackney" <DustyHackney@.discussions.microsoft.com> wrote in message
news:ACB59DED-E104-4EB0-8860-EB0883C40CA5@.microsoft.com...
> No. I am using VB and .NET 1.x. So far, I haven't figured out how to
> accomplish seeing if a user is a member of a group by providing a function
a
> username and a group name (but no password).
>
> "Jaret Langston" wrote:
>
check
issue?
different

0 comments:

Post a Comment