473,666 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Windows Identity)
Dim result As Object = idType.InvokeMe mber("_GetRoles ",
BindingFlags.St atic Or BindingFlags.In vokeMethod Or
BindingFlags.No nPublic, Nothing, id, New Object() {id.Token}, Nothing)
Dim roles() As String = DirectCast(resu lt, String())

Dim i As Integer
Do Until i = roles.GetUpperB ound(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 1885
Henry,

You need to set <identity impersonate="tr ue"/> 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******** *************@g 47g2000cwa.goog legroups.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(Windows Identity)
Dim result As Object = idType.InvokeMe mber("_GetRoles ",
BindingFlags.St atic Or BindingFlags.In vokeMethod Or
BindingFlags.No nPublic, Nothing, id, New Object() {id.Token}, Nothing)
Dim roles() As String = DirectCast(resu lt, String())

Dim i As Integer
Do Until i = roles.GetUpperB ound(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="tr ue"/> 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="tr ue"/> 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******** *************@g 47g2000cwa.goog legroups.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(Windows Identity)
Dim result As Object = idType.InvokeMe mber("_GetRoles ",
BindingFlags.St atic Or BindingFlags.In vokeMethod Or
BindingFlags.No nPublic, Nothing, id, New Object() {id.Token}, Nothing)
Dim roles() As String = DirectCast(resu lt, String())

Dim i As Integer
Do Until i = roles.GetUpperB ound(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.goo glegroups.com.. .
Hi Justin,
It worked, i just
1) Added <identity impersonate="tr ue"/> 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="tr ue"/> 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******** *************@g 47g2000cwa.goog legroups.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(Windows Identity)
> Dim result As Object = idType.InvokeMe mber("_GetRoles ",
> BindingFlags.St atic Or BindingFlags.In vokeMethod Or
> BindingFlags.No nPublic, Nothing, id, New Object() {id.Token}, Nothing)
> Dim roles() As String = DirectCast(resu lt, String())
>
> Dim i As Integer
> Do Until i = roles.GetUpperB ound(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_"MACHINENA ME".

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.goo glegroups.com.. .
Hi Justin,
It worked, i just
1) Added <identity impersonate="tr ue"/> 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="tr ue"/> 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******** *************@g 47g2000cwa.goog legroups.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(Windows Identity)
> Dim result As Object = idType.InvokeMe mber("_GetRoles ",
> BindingFlags.St atic Or BindingFlags.In vokeMethod Or
> BindingFlags.No nPublic, Nothing, id, New Object() {id.Token}, Nothing)
> Dim roles() As String = DirectCast(resu lt, String())
>
> Dim i As Integer
> Do Until i = roles.GetUpperB ound(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 "Impersonat or" 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******** *************@g 43g2000cwa.goog legroups.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_"MACHINENA ME".

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.goo glegroups.com.. .
> Hi Justin,
> It worked, i just
> 1) Added <identity impersonate="tr ue"/> 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="tr ue"/> 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******** *************@g 47g2000cwa.goog legroups.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(Windows Identity)
>> > Dim result As Object = idType.InvokeMe mber("_GetRoles ",
>> > BindingFlags.St atic Or BindingFlags.In vokeMethod Or
>> > BindingFlags.No nPublic, Nothing, id, New Object() {id.Token},
>> > Nothing)
>> > Dim roles() As String = DirectCast(resu lt, String())
>> >
>> > Dim i As Integer
>> > Do Until i = roles.GetUpperB ound(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
4455
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 list with all the groups). Thanks!
1
2965
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 Global scope and Domain local scope. Does anyone know I can modify the following code to this? DirectoryEntry entry = new DirectoryEntry("LDAP://" + Domain, CurrentUser, pwd, AuthenticationTypes.Secure); DirectorySearcher mySearcher = new...
4
2172
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 okay is for the actual csv of each log. The second one parses out the description of the log. My problem is with the accesses section of the description. How do I parse multiple groups that have the same name. When I do a for each through the...
11
4849
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 name that is found on the Workstation Locked screen between the ( )'s. Does anyone know how to do that? The only constraint: no use of ActiveDS.dll permitted by the design. Many thanks! Derek
6
2138
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 Regards
5
3784
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 directory. When i click submit, I want to add the username from textbox1 into the local administrators group on the computer name from textbox2. I want to do this in asp.net using vb.net as the programming language.
10
26800
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
5684
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 *************************************************************************************************** DirectoryEntry AD = new DirectoryEntry("WinNT://" + sServerName + ",Computer",UserName,Password); DirectoryEntry admGroup = AD.Children.Find("Administrators", "Group"); object members = admGroup.Invoke("Members", null); ...
5
13195
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 Properties collection I can't get the properties on some users. For example, I get all the users that are part of my machines Administrators Group. I get get the properties of the built in local Administrator account and some local IT account,...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.