HighTechTalks DotNet Forums  

Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set

ASP.net Security microsoft.public.dotnet.framework.aspnet.security


Discuss Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set in the ASP.net Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Reine Olofsson
 
Posts: n/a

Default Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set - 09-01-2003 , 01:49 AM






Hi all

I'm trying to implement access check in my web application based on the
current
user.
I've tried using the IsInRole method but have discoverad that it lacks one
important feature. It doens't return TRUE if the user belongs to a domin
group added to the local group i'm checking..
Sample:
User 'MyUser' is a member of DOMAIN\Developers
DOMAIN\Developers is a member of LOCALSERVER\AppUsers
When i run myCredential.IsInRole("LOCALSERVER\AppUsers") the return value is
False. If I add 'MyUser' to LOCALSERVER\AppUsers excplicitly it works, but
that's not an option.
Can I somehow get the funtionality of the NetApi32 function
NetUserGetLocalGroups with the flag LG_INCLUDE:INDIRECT? Does anyone have
any sample code for declaring and using the NetUserGetLocalGroups function
in VB.Net?

Regards
Reine Olofsson
Developer




Reply With Quote
  #2  
Old   
Reine Olofsson
 
Posts: n/a

Default Re: Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set - 09-01-2003 , 05:46 AM






Problem solved:

Public Function GetLocalRoles(ByRef winIdentity As WindowsIdentity) As
String()
Dim iCount, iMax As Integer
Dim vRoles() As String
Dim sLocalRoles, sLocalServer As String
Dim vLocalRoles() As String
Dim idType As Type
Dim result As Object

sLocalServer = Environment.MachineName.ToUpper
idType = GetType(System.Security.Principal.WindowsIdentity)
result = idType.InvokeMember("_GetRoles", _
BindingFlags.Static Or BindingFlags.InvokeMethod Or
BindingFlags.NonPublic, _
Nothing, winIdentity, New Object() {winIdentity.Token}, Nothing)
vRoles = DirectCast(result, String())

iMax = vRoles.Length - 1
For iCount = 0 To iMax
If vRoles(iCount) <> "" Then
If vRoles(iCount).ToUpper.StartsWith(sLocalServer) Then
sLocalRoles += vRoles(iCount).Remove(0, sLocalServer.Length + 1) +
";"
End If
End If
Next
If sLocalRoles <> "" Then
vLocalRoles = sLocalRoles.Split(";".ToCharArray)
Return vLocalRoles
End If
End Function
/Reine Olofsson


"Reine Olofsson" <reine (AT) faktab (DOT) se> wrote

Quote:
Hi all

I'm trying to implement access check in my web application based on the
current
user.
I've tried using the IsInRole method but have discoverad that it lacks one
important feature. It doens't return TRUE if the user belongs to a domin
group added to the local group i'm checking..
Sample:
User 'MyUser' is a member of DOMAIN\Developers
DOMAIN\Developers is a member of LOCALSERVER\AppUsers
When i run myCredential.IsInRole("LOCALSERVER\AppUsers") the return value
is
False. If I add 'MyUser' to LOCALSERVER\AppUsers excplicitly it works, but
that's not an option.
Can I somehow get the funtionality of the NetApi32 function
NetUserGetLocalGroups with the flag LG_INCLUDE:INDIRECT? Does anyone have
any sample code for declaring and using the NetUserGetLocalGroups function
in VB.Net?

Regards
Reine Olofsson
Developer






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.