473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting Groups of a User in a Domain

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 :)

Nov 19 '05 #1
5 1862
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
<he***********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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 :)

Nov 19 '05 #2
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. Justin Gengo wrote:
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
<he***********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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 :)


Nov 19 '05 #3
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
<he***********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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. Justin Gengo wrote:
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
<he***********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
> 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 :)
>

Nov 19 '05 #4
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. Justin Gengo wrote:
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
<he***********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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. Justin Gengo wrote:
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
<he***********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
> 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 :)
>


Nov 19 '05 #5
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
<he***********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
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. Justin Gengo wrote:
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
<he***********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
> 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. Justin Gengo wrote:
>> 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
>> <he***********@gmail.com> wrote in message
>> news:11*********************@g47g2000cwa.googlegro ups.com...
>> > 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 :)
>> >
>

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: uiranejeb | last post by:
How can I determine the windows groups from a domain? How can I determine all the windows groups to which a user belongs to? (WindowsPrincipal says if a user belongs to a specific group. I need a...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I'm having a problem with reading user groups on Active Directory using C#. It returns all the groups in the Universal scope for a specific user. However, I only need the groups in...
4
by: Ben Dewey | last post by:
Hey, I have only been playing with regular expressions for some time. I am working on some code that parses and object 560 event log. I have created two expressions the first one which works...
11
by: Derek Martin | last post by:
Using VB.Net, I would like to retrieve the currently logged in user's DN from Active Directory. Alternatively, if, using WindowsIdentity, or something similar, I would like to get the user's full...
6
by: Mr Newbie | last post by:
Hi, Im in a situation where I need to restrict users, but I dont have access or wont be allowed access to manage groups in the domain. How can I restrict access is this case ? -- Best...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
10
by: Jeff Williams | last post by:
How can I get a list of the Groups both Local and Domain groups a User belongs to.
4
by: shashank kadge | last post by:
hi all, i am trying to get local admin users and groups on a windows server. here is the C# code that i am using...
5
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.