473,372 Members | 1,070 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,372 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 1860
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.