Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set

    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



    Reine Olofsson Guest

  2. Similar Questions and Discussions

    1. KTML replacement?
      Hi guys, I used to work with KTML with my old Dreamweaver. Now I moved on to DW CS3 and KTML doesn't work any more... Do anbybody knows any...
    2. connectstring replacement
      Previously in CF5, we would pass the persons username in the connectstring attribute of cfquery. Then using SQL Profiler for MS SQL Server, we could...
    3. Media replacement
      Our CD went missing how do I optain a new CD? Thanks
    4. Word replacement
      Hi There, How do I read a file and replace all occurences of a word in it with another word. For example, I want to read the file BUS_SCHEDULE...
    5. text replacement+
      Hi everyone, I have a following data to analyze : --------- BlockA color 0 0 0 rcolor 1 1 1 dcolor 2 2 2 BloackB
  3. #2

    Default Re: Replacement for NetUserGetLocalGroups with LG_INCLUDE_INDIRECT set

    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@faktab.se> wrote in message
    news:eHYZFVFcDHA.3620@TK2MSFTNGP11.phx.gbl...
    > 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
    >
    >
    >

    Reine Olofsson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139