Getting Groups of a User in a Domain

H

henrycortezwu

Hi All,
I'm trying to get the "groups" of a user that belongs to a domain by
just passing the user's userID & domain. Is this possible?

What I tried, and is working is the ff code ( i can get both local &
domain groups), but in Windows Application.

When I tried converting it to ASP.NET, it only gets the local
groups.

Dim id As WindowsIdentity = WindowsIdentity.GetCurrent()

Dim idType As Type
idType = GetType(WindowsIdentity)
Dim result As Object = idType.InvokeMember("_GetRoles",
BindingFlags.Static Or BindingFlags.InvokeMethod Or
BindingFlags.NonPublic, Nothing, id, New Object() {id.Token}, Nothing)
Dim roles() As String = DirectCast(result, String())

Dim i As Integer
Do Until i = roles.GetUpperBound(0)
Me.tbxAPI.Text = Me.tbxAPI.Text & roles(i) & vbCrLf
i = i + 1
Loop

Anyone knows how to make the code above possible in ASP.NET?
Maybe i just need to configure my IIS?

Pls help.

Thanks,
Henry :)

P.S. I'm a newbie in ASP.NET :)
 
S

S. Justin Gengo

Henry,

You need to set <identity impersonate="true"/> in the application's
web.config file and also set the website to use windows integrated security
in IIS.


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
H

henrycortezwu

Hi Justin,
It worked, i just
1) Added <identity impersonate="true"/> at the web config
2) Checked ONLY windows integrated security

Thanks so much.

Last question though, how can i get the same result if i want to check
the Anonymous selection at the IIS Direcotry Security?

When I checked it, it only gets the "entered" user's groupings, but
what we want is the "client/current" user's groups.

Thanks,
Henry :)
 
S

S. Justin Gengo

Henry,

Would you be able to explain your last request with different wording and/or
more detail. I'm afraid I'm not understanding exactly what you need.

Thanks,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
H

henrycortezwu

Hi Justin,
Under the Authentication Methods Dialog Box, there is a Anonymous
Access Check Box. I would like to have this "Checked" and at the same
time make the "Get User Groupings" function work.

I tried checking this checkbox and running the webpage and what the
"Get User Groupings" function got was the groupings of
IUSR_"MACHINENAME".

Any configuration I can do to allow Anonymous Access, and have my
website "Get User Groupings" of the domain/client browsing?

Thanks,
Henry :)
 
S

S. Justin Gengo

Henry,

You would have to create an account to get the groupings with.

I found an impersonation tutorial which is technically for sharepoint. But
the article shows how to create an "Impersonator" class which it will be
helpful for you to look at. Even though this is geared toward sharepoint
what's being done is the same as you want to do:

http://www.15seconds.com/issue/040511.htm

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top