Output List of User's Groups

369

Solution 1

dsquery user -name "My Full Name" | dsget user -memberof | dsget group -samid

I found this pretty much gives me what I was looking for, in case anyone was curious! :)

Solution 2

Use PowerShell!

$user = [wmi] "Win32_UserAccount.Name='JohnDoe',Domain='YourDomainName'"
$user.GetRelated('Win32_Group')

or only for group names:

$user = [wmi] "Win32_UserAccount.Name='JohnDoe',Domain='YourDomainName'"
$user.GetRelated('Win32_Group') | Select Name

http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/67defa12-6ad1-439b-bd11-3abfc5b5208a/

Solution 3

Hmm.

net user paul /domain | find "Global Group memberships"

Will give you the the groups, but if you don't want the header you'd need something more involved:

for /f "tokens=4*" %f in ('net user paul /domain ^| find "Global Group memberships"') do echo %f

So %f contains the groups.

Share:
369

Related videos on Youtube

Rajan
Author by

Rajan

Updated on September 18, 2022

Comments

  • Rajan
    Rajan over 1 year

    see thisi was working on Codeigniter Application in WAMP and then i had to move my project to a LINUX machine.

    Now When i have installed LAMP there. but When i try to access my application i get an error:

    An Error Was Encountered

    Unable to load the requested file: helpers/url_helper.php

    i checked my autoload.php. This worked on my windows don't why its not working here.

    $autoload['helper'] = array('url','html','crm_helper','form');
    

    Can you please guide me where i am going wrong?

    • Admin
      Admin over 12 years
      Is writing a custom tool in Python or C# acceptable?
    • Admin
      Admin over 12 years
      That's beyond my capabilities but if you can get me something that I can compile and execute I'd certainly be very thankful :)
    • Admin
      Admin over 12 years
      This isn't something you'd normally want to do in Windows. Can you explain why you want the output in this particular format? We may be able to suggest an alternative.
    • saurabh kamble
      saurabh kamble over 8 years
      which one is not working add one by one and check
    • itsols
      itsols over 8 years
      Did you copy the folders from Windows to Linux or is it a fresh installation from download?
    • itsols
      itsols over 8 years
      I think your problem is that you don't have the crm_helper in the correct path, or you don't have it at all.
    • Rajan
      Rajan over 8 years
      once i remove any helper from the autoload it start pointing to other helper for error @saurabhkamble
    • Rajan
      Rajan over 8 years
      @itsols i removed crm_helper from my autoload still doesnt works
    • saurabh kamble
      saurabh kamble over 8 years
      @Rajan add that error in the question
    • Rajan
      Rajan over 8 years
      i already have its just shows me Unable to load the requested file: helpers/url_helper.php
    • Rajan
      Rajan over 8 years
      i have added the screen shot see @saurabhkamble
    • saurabh kamble
      saurabh kamble over 8 years
      @Rajan your are using url function and you not auto-loaded url helper now just add url helper in it
    • Rajan
      Rajan over 8 years
      @saurabhkamble so i should manually load the url helper? or shall i put it in autload.php?
    • saurabh kamble
      saurabh kamble over 8 years
      @Rajan try both ways
    • Rajan
      Rajan over 8 years
      tried both @saurabhkamble but i think there is some reconfiguration in my installation so
    • saurabh kamble
      saurabh kamble over 8 years
    • Tpojka
      Tpojka over 8 years
      Use master version instead of develop one.
  • Smitty
    Smitty over 12 years
    Thanks, that kinda looks like what I'm after but the first example only outputs data from that line, if there are say a dozen groups, most won't show and the second example you gave is giving me the error "f was unexpected at this time" from what I gather, it's not liking the final "%f", I'm just a beginner with these batch scripts :)
  • Paul
    Paul over 12 years
    If you use it in a script, you need to use %%f. Yes, good point, the output will wrap and get lost. Do you have an output you can paste, I don't have the right setup to test. It may need something more robust than hacking bits out of the net user command :)