Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4580626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:48:35+00:00 2026-05-21T20:48:35+00:00

I’m trying to match up a specific group name and see if it exists

  • 0

I’m trying to match up a specific group name and see if it exists for the currently logged in user using Active Directory roles. If the Group Name exists for the Current User, I want that group name to be displayed in a drop down list.
Example: If current user is in BIG Group, display BIG in drop down list.

Problem: All I am getting is SIDs and I’m not able to get anything to match up to the group name and nothing will show up in the drop down list.

I also get the following Error:

         Error: Object variable or WIth block variable not set.

How do I fix this??

here is the code I am using:

Private Sub GetMarketingCompanies()

        ' code to populate marketing company drop down list based on the current logged in users active directory group that 
        ' corresponds to which marketing company they are in 

        Dim irc As IdentityReferenceCollection
        Dim ir As IdentityReference
        irc = WindowsIdentity.GetCurrent().Groups
        Dim strGroupName As String

        For Each ir In irc
            ' Dim mktGroup As IdentityReference = ir.Translate(GetType(NTAccount))
            MsgBox(mktGroup.Value)
            Debug.WriteLine(mktGroup.Value)
            strGroupName = mktGroup.Value.ToString
        Next 

        For Each UserGroup In WindowsIdentity.GetCurrent().Groups
            If mktGroup.Value = "BIG" Then
                Dim Company = ac1.Cast(Of MarketingCompany).Where(Function(ac) ac.MarketingCompanyShort = "BIG").FirstOrDefault
                If Company IsNot Nothing Then
                    marketingCo.Items.Add(String.Format("{0} | {1}", Company.MarketingCompanyShort, Company.MarketingCompanyName))
                End If
            End If
        Next

Thanks for looking!
Any helpful answers will be up-voted!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:48:36+00:00Added an answer on May 21, 2026 at 8:48 pm

    I ended up doing the following to fix the code:

    • deleting the the For loop that calls UserGroup In WindowsIdentity.GetCurrent().Groups
    • putting all the code under the For Each Loop that calls IdentityReference In IdentityReferenceCollection
    • adding mcisloaded boolean variable to make the admin, not admin if statements work
    • disabling MsgBox(mktGroup.Value) as this was just for trial and error to see what values were getting returned

    Here’s the code:

    Private Sub GetMarketingCompanies()
        Try
            Dim ac1 As Array
            ac1 = proxy.GetMarketingCompanyNames("test", "test")
    
            ' code to populate marketing company drop down list based on the current logged in users active directory group that 
            ' corresponds to which marketing company they are in 
    
            Dim irc As IdentityReferenceCollection
            Dim ir As IdentityReference
            irc = WindowsIdentity.GetCurrent().Groups
            Dim strGroupName As String
            Dim mcisloaded As Boolean
    
            ' Translate the current user's active directory groups 
    
            For Each ir In irc
                Dim mktGroup As IdentityReference = ir.Translate(GetType(NTAccount))
                ' MsgBox(mktGroup.Value)
                Debug.WriteLine(mktGroup.Value)
                strGroupName = mktGroup.Value.ToString
    
                ' If the user is in the admin group, load all marketing companies   
                If mktGroup.Value = "ALG\ACOMP_USER_ADMIN" Then
                    mcisloaded = True
                    For Each item In ac1
                        marketingCo.Items.Add(String.Format("{0} | {1}", item.MarketingCompanyShort, item.MarketingCompanyName))
                    Next
                End If
    
                'If the user is not in the admin group, load marketing companies individually
                If Not mktGroup.Value = "ALG\ACOMP_USER_ADMIN" Then
                    mcisloaded = False
    
                    If mcisloaded = False Then
    
                        If mktGroup.Value = "ALG\ACOMP_USER_BIG" Then
                            Dim Company = ac1.Cast(Of MarketingCompany).Where(Function(ac) ac.MarketingCompanyShort = "BIG").FirstOrDefault
                            If Company IsNot Nothing Then
                                marketingCo.Items.Add(String.Format("{0} | {1}", Company.MarketingCompanyShort, Company.MarketingCompanyName))
                            End If
                        End If
    
                        If mktGroup.Value = "ALG\ACOMP_USER_AMG" Then
                            Dim Company = ac1.Cast(Of MarketingCompany).Where(Function(ac) ac.MarketingCompanyShort = "AMG").FirstOrDefault
                            If Company IsNot Nothing Then
                                marketingCo.Items.Add(String.Format("{0} | {1}", Company.MarketingCompanyShort, Company.MarketingCompanyName))
                            End If
                        End If
    
                        ' ... Code for loading the rest of the marketing groups 
    
                    End If
                End If
    

    Update 6-7-11: Here’s a cleaner version of cycling through all the active directory group names by using a string splitter to get the last 3 letters that identifies the marketing company, instead of a series of if statements for each marketing company:

    Private Sub GetMarketingCompanies()
        Try
            Dim marketingCompanyNamesArray As Array
            marketingCompanyNamesArray = proxy.GetMarketingCompanyNames("test", "test")
    
            ' code to populate marketing company drop down list based on the current logged in users active directory group that 
            ' corresponds to which marketing company they are in 
    
            Dim identityReferenceCollection As IdentityReferenceCollection
            Dim identityReference As IdentityReference
            identityReferenceCollection = WindowsIdentity.GetCurrent().Groups
            Dim strGroupName As String
            Dim mcisloaded As Boolean
    
            ' Translate the current user's active directory groups 
            For Each identityReference In identityReferenceCollection
                Dim mktGroup As IdentityReference = identityReference.Translate(GetType(NTAccount))
                ' MsgBox(mktGroup.Value)
                ' Debug.WriteLine(mktGroup.Value) 
                strGroupName = mktGroup.Value.ToString
    
                ' Locally User group is ALG\ACOMP_USER_ADMIN , deployed ALGWEB\ACOMP_USER_ADMIN
                ' If the user is in the admin group, load all marketing companies   
                If mktGroup.Value = "ALG\ACOMP_USER_ADMIN" Then
                    mcisloaded = True
                    For Each item In marketingCompanyNamesArray
                        marketingCo.Items.Add(String.Format("{0} | {1}", item.MarketingCompanyShort, item.MarketingCompanyName))
                    Next
    
                Else
                    'If not admin user (mcisloaded = False) load each group individually if it appears in AD 
                    ' For Each UserGroup In WindowsIdentity.GetCurrent().Groups that begins with ALG\ACOMP_USER, load marketing companies 
    
                    Dim MarketingCompanyShortName As String = ""
                    Dim mktGroupName As String = mktGroup.Value
                    If mktGroupName.StartsWith("ALG\ACOMP_USER") Then
                        Dim marketingGroupNameParts() As String = Split(mktGroupName, "_")
                        'Load MarketingCompanyShortName from the end of marketingGroupNameParts - example: ACOMP_USER_BIG
                        MarketingCompanyShortName = marketingGroupNameParts(2)
    
                        'If MarketingCompanyShortName exists, load it into the dropdownlist 
                        Dim Company = marketingCompanyNamesArray.Cast(Of MarketingCompany).Where(Function(ac) ac.MarketingCompanyShort = MarketingCompanyShortName).FirstOrDefault
                        If Company IsNot Nothing Then
                            marketingCo.Items.Add(String.Format("{0} | {1}", Company.MarketingCompanyShort, Company.MarketingCompanyName))
                        End If
    
                    End If
                End If 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.