List all AD users with memberof

Hi I have got this script and it works fine, but I cant add the memberof groups for each user. 
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Const ADS_UF_ACCOUNTDISABLE = &H0002
Const ADS_UF_PASSWD_NOTREQD = &H0020
Const ADS_UF_PASSWD_CANT_CHANGE = &H0040
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Const ADS_UF_SMARTCARD_REQUIRED = &H40000
'Set RootDSE
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = objRootDSE.Get("defaultNamingContext")
strADPath = "LDAP://" & strDomain
'wscript.Echo strADPath
Set objDomain = GetObject(strADPath)
'wscript.echo "objDomain: " & objDomain.distinguishedName
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "SAURON"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name, description, sAMAccountName, st, postalCode, co, l, profilePath, homeDrive, distinguishedName,userAccountControl FROM '"& strADPath &"' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set objFSO = CreateObject("scripting.filesystemobject")
Set logStream = objFSO.opentextfile("C:users\dom.adm.pa\desktop\domainusers.csv", 8, True)
logStream.writeline("Name,Description,sAMAccountName,st,postalCode,co,l,Account Disabled,Password Required,User Changable Password,Password Expires,Login Count,Last Login,Last Password Change,Created,Modified")
Do Until objRecordSet.EOF
strDN = objRecordset.Fields("distinguishedName").Value
Set objUser = GetObject ("LDAP://" & strDN)
If objRecordset.Fields("userAccountControl").Value AND ADS_UF_ACCOUNTDISABLE Then
Text = "Yes"
Else
Text = "No"
End If
If objRecordset.Fields("userAccountControl").Value AND ADS_UF_PASSWD_NOTREQD Then
Text = Text & ",No"
Else
Text = Text & ",Yes"
End If
If objRecordset.Fields("userAccountControl").Value AND ADS_PASSWORD_CANT_CHANGE Then
Text = Text & ",No"
Else
Text = Text & ",Yes"
End If
If objRecordset.Fields("userAccountControl").Value AND ADS_UF_DONT_EXPIRE_PASSWD Then
Text = Text & ",No"
Else
Text = Text & ",Yes"
End If
logStream.writeline(objRecordset.Fields("Name").Value & ","_
& objRecordset.Fields("description").Value & ","_
& objRecordset.Fields("sAMAccountName").Value & ","_
& objRecordset.Fields("st").Value & ","_
& objRecordset.Fields("postalCode").Value & ","_
& objRecordset.Fields("co").Value & ","_
& objRecordset.Fields("l").Value & ","_
& objUser.logonCount & ","_
& objUser.LastLogin & ","_
& objUser.PasswordLastChanged & ","_
& objUser.whenCreated & ","_
& objUser.whenChanged & ","_
Loop
logStream.Close

Are you looking for members:
1) in a specific group, or
2) list all users and all their direct groups, or
3) get a complete list of all groups a user is a memberof, to include nested?
I would recommend using Powershell.  It's made for this type of thing.  Some of the Cmdlets you can check are:
List all users with all groups:
Get-ADUser -filter * -properties memberof | select samaccountname,memberof
List all members of a group:
Get-ADGroupmember <groupname> -recursive
Get all groups a member is nested in:
Get-ADAccountAuthorizationGroup <username> | ft name
- Chris Ream -
**Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

Similar Messages

  • Can we list all the users or groups with there rights on the universe\s

    Can we list all the users or groups with there rights on the universe\s using query builder.
    Can we do the same by using auditor reports.
    PLZ  help

    Thanks ,
    It can be acihived by using secuirty viewer.
    Thanks again

  • How to get list of active users with the details like samaccountname, name, department, job tittle, email in active directoy?

    how to get list of active users with the details like samaccountname, name, department, job tittle, email in active directoy?

    You can use third party software True Last Logon 2.9.You can export the file in excel for report creation.You can use the trial version this will achieve what you are looking for.
    True Last Logon displays the following Active Directory information:
    --Users real name and logon name
    --Detailed account status
    --Last Logon Date & Time
    --Last Logon Timestamp (Replicated value)
    --Account Expiry Date & Time
    --Enabled or Disabled Account
    --Locked Accounts
    --Password Expires
    --Password Last Set Date & Time
    --Logon Count
    --Bad Password Count
    --Expiry Date
    --You can also query for any other attribute (Example: Description, telephone Number, custom attibutes etc)
    Refer the below link for trial version:
    http://www.dovestones.com/products/True_Last_Logon.asp
    Best Regards,
    Sandesh Dubey.
    MCSE|MCSA:Messaging|MCTS|MCITP:Enterprise Adminitrator |
    My Blog
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • List all Virtual Machines with Associated Tags

    I have custom attributes for application engineer, OS engineer, application name, etc. In the vSphere Client I can list all VMs and their custom attributes.  I can then sort the list by custom attribute.  Doing this allows me to find virtual machines with empty custom attributes.
    I have converted my custom attributes to tags.  I cannot find a way to list all virtual machines with associated tags in the vSphere Web Client.  Is there a way to do this using PowerCLI? I'd like to be able to produce a CSV file that contains all virtual machines and their associated tags.

    If you have tag assignments for the category of "OS engineer".  You can write this:
    Get-TagAssignment -Category "OS engineer"
    That will list the tags in the category and the associated VMs.

  • List of Portal users with the assigned Roles.....

    Hello All,
    I am working on EP6 SP9 and want to know from where can I get a list of all Portal users along with the assigned roles for each of them.
    One way I found is by searching for all users in User Administration role and along with the searched users, there is also an icon for Assigned roles.
    Apart from the above mentioned way, is there any other way by which I can get a direct list of the same. Is there a Java sample code for this.....?
    Please help.
    Awaiting Reply.
    Thanks and Warm Regards,
    Ritu R Hunjan

    Hi Ritu,
    Yes it is possible to get the roles of the users. You can try the following java code.
    package com.hcl.user;
    import java.util.Iterator;
    import java.util.Vector;
    import com.sap.security.api.IRole;
    import com.sap.security.api.IRoleFactory;
    import com.sap.security.api.IRoleSearchFilter;
    import com.sap.security.api.ISearchResult;
    import com.sap.security.api.IUser;
    import com.sap.security.api.IUserAccount;
    import com.sap.security.api.IUserFactory;
    import com.sap.security.api.UMFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class role_member extends AbstractPortalComponent {
    public void doContent(
    IPortalComponentRequest request,
    IPortalComponentResponse response) {
    try {
    IUserFactory userfactory = UMFactory.getUserFactory();
    IRoleFactory rolefactory = UMFactory.getRoleFactory();
    IRoleSearchFilter rolefltr = rolefactory.getRoleSearchFilter();
    rolefltr.setMaxSearchResultSize(2000);
    ISearchResult result = rolefactory.searchRoles(rolefltr);
    while (result.hasNext()) {
    response.write("<table border=0>n");
    String uniqueid = (String) result.next();
    IRole role = rolefactory.getRole(uniqueid);
    response.write("<tr><td bgcolor=Red>"+ role.getDisplayName()+ "</tr></td>n");
    Iterator users = role.getUserMembers(true);
    while (users.hasNext()) {
    String unique_user = (String) users.next();
    IUser user = userfactory.getUser(unique_user);
    IUserAccount account[] = user.getUserAccounts();
    response.write(
    "<tr><td>" + account[0].getLogonUid() + "</tr></td>n");
    response.write("</table>n");
    response.write("</br>n");
    } catch (Exception e) {
    This code gives you the list of all the users of your portal along with the roles assigned to them.
    Apart from this if you want you want to know all the roles assigned to the user on portal itself then the way you mentioned is the correct method.
    Regards
    Pravesh
    PS: Please consider awarding points.

  • How to list all OID Users

    Hello,
    I have Oracle OID synchronized with my LDAP directory, i need a pl/sql statement that returns all the users in LDAP directory.
    Any Ideas ?
    Regards,
    Hussam

    Hi Paul
                        Well although writing a simple Portal Application is quite a straight forward method of approaching it, but I think you could also retrieve the mapping data using a AppIntegtrator iView.
    Please have a look at this thread , where there is a link to Will Carltons paper, which explains on how to do that.
    How to access user id and password via UserMapping ?
    Give it a shot!
    Cheers.
    Award points for helpful answers.

  • Sunone Messaging Server 6.1--How to list all mail user's last login time

    hi,i want to know how to list all the mail user's last login time.
    There are more than 100000 mailbox accounts on our mail server,
    i want to know which account is not used for more than 2 or 3 years.
    thanks.

    http://wikis.sun.com/display/CommSuite/imsconnutil
    Somchai.

  • To find all the users with 2 tcodes

    Hi,
          I have 2 transaction codes with me MIGO,MI07.I want to know the users who have both these transaction codes. I tried to find out using SUIM. But I could only find users with each transaction code seperately. Can anyone suggest me a way to find out the users with both these tcodes.

    Hi Ravi
    There is one way this can be identified for future ref, we have an SQL script that links up to R/3 and logs every incident go T/codes of every user.
    Hope this is helpful
    Rgds....BK

  • List all form fields with JS?

    I imagine this is a pretty easy one, but does anyone know what the script would be to list all form fields in the console?  Specifically, at the moment, I only need it for buttons, but I imagine it would be useful for any fields as well.

    Take a look at the "Required Fields" tool at this site:
    http://www.pdfscripting.com/public/65.cfm
    Its a toolbar button that lists all fields that are required. It could easily be changed to filter for any field parameter, or none.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    http://www.adobe.com/devnet/acrobat/javascript.html
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)

  • Giving List Permission to users with no access to the main site

    On my sub site I have a list (where users from a specific store can report errors). This list I want to share with another group of users, those who will do something about the errors (entrepreneurs). I want them to be able to Edit in this list: they don't
    need delete and create items, just being able to change an item is fine. 
    The problem is, I don't want them to have access to the sub site itself, because there is  information on the sub site that they don't need to know about, they should only see this list. So they don't have any access at all to the sub site, but I'm giving
    them permission to the list. 
    However, it seems like since they can't access the sub site, no matter what permission I give them to the list (Edit, Contribute, Full Control), in the end they only have Reading-access to the list and can't even update an item. 
    This error message turns up whenever they try:
    "Unable to communicate with server".
    The entrepreneur group is external users, but that shouldn't matter, should it? I've added them to SharePoint groups with the right permissions.
    Is there any possible way to solve this problem?

    Hi  ,
    Here is the steps you can refer to:
    Go to your site ->Site Settings ->Site permissions ->Permission Levels ->Click “Add a Permission Level” and create a custom permission level with following permissions : 
    Edit Items, View Items, Open Items, View Pages , Open.
    Go to your list ->Shared With -> INVITE PEOPLE : 
    input your group, click  “SHOW OPTIONS” 
    and select the new custom permission level.
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • List of exchange users with mailbox size per database.

    Hello Friends,
    Need small help i need to take out the list of users start with Alphabet A, B , C till Z per database along with their mailbox size limit so is there any simple way to get the list.
    Thanks
    Amit

    Hi,
    How about this?
    http://help.outlook.com/en-us/140/gg576861.aspx
    EDIT: Or maybe this:
    $out = @()
    $users = Get-Mailbox -ResultSize Unlimited
    ForEach ($user in $users) {
    $userMailboxStatistics = Get-MailboxStatistics $user
    $props = @{
    Username = $user.SamAccountName
    DisplayName = $user.DisplayName
    Database = $user.Database
    OrganizationalUnit = $user.OrganizationalUnit
    'Quota Status' = $userMailboxStatistics.StorageLimitStatus
    TotalItemSize = $userMailboxStatistics.TotalItemSize
    $out += New-Object PsObject -Property $props
    $out | Sort-Object Database,DisplayName | Export-Csv .\mbxDetails.csv -NoTypeInformation
    Adjust the $props hash as needed to add/remove properties to the output object.
    Don't retire TechNet! -
    (Don't give up yet - 12,420+ strong and growing)

  • Std. Transaction / Report to List all PO's with no invoice posting

    Hi All,
    I would like to know is there a standard transaction or report, which lists out all PO's for which goods receipt has been done, but invoice posting has not been done?
    Vivek

    Hi All,
    Thanks for your inputs,
    1. MR11 - Can you please let me know what input conditions do i have to give, to view only those PO's for which GR is done & Invoice not posted, because when i run this transaction it is showing all PO's which have invoice posted as well.
    2. ME2M - I am not able to select the dynamic selection option, it is in grey, how do i activate it?
    3. ME80FN - This gives a list of PO's line wise, but what i need is all PO lines for which GR is done, but no invoice posted.
    Await inputs.
    Vivek

  • How to show the all the users with dequeue or enqueue privileges on a queue

    Hi
    As dba I want to know which users has which rights on a queue.
    Is there a sys table or view where I can see that?
    Something like dba_tab_privs for tables etc.
    Or is the there a plsql procedure which can help me?
    ruud van der wal

    yes... dba_tab_privs
    select * from dba_tab_privs where privilege in ('ENQUEUE','DEQUEUE');

  • Tcode to view the list of all dialog users in SAP XI

    Dear all,
    What is the Tcode to view the list of all dialog user is SAP XI system.
    I checked with SU01, it doesn't have a option to display the list of existing users.
    Any other Tcode for this purpose.
    Regards,
    Younus

    Hi..
    T-code  AL08 -> list all logged users(user login logon)
    Regards..
    krishna..

  • NDS Gateway Active Sync Listing All users on each poll

    When Sun Identity Manager 6.0 sp1 runs an active sync poll event with the NDS Resource Adapter against the Gateway the following behaviour is exhibited within both the customer environment and the Lab environment.
    The Gateway will list all the users using the Novell Client, even users who have not had their modification timestamp updated since the last poll.
    The Gateway will then return the relevant users to the Sun Identity Manager application. Using the Search Parameter modification timestamp as can be seen below.
    �<SearchParameters>
    <Map>
    <MapEntry key='modificationTimestampFilter'>
    <Long>1166504812</Long>
    </MapEntry>
    </Map>
    </SearchParameters>
    This is causing the Synchronisation process at the customer to take much longer than necessary. Every time Sun Identity Manager polls the resource all the users are listed within the gateway service.
    Can you please confirm if this is the expected behaviour? Or should the gateway only be listing users that have been updated since the last poll event.

    Their is an issue with the NDS adapter. Contact Sun support, they have an appliance that can be installed to rectify.
    Good luck.

Maybe you are looking for

  • Error regarding Number ranges in MIRO

    Guys   Iam getting the following error while am assigning MIRO can u please suggest me a solution for getting rid of this error In FBN1 am trying assign 51 for my company but it says tat the number overlapps....what shall i do for the following probl

  • Fetch into object type

    Oracle 10.2.0.5.0 Using Pl/SQL Developer Hi I'm new to collections, object types etc, so I aologize for any poor wording and missed concepts... I need to output a ref cursor from my package (for a summary report in SQL Server Reporting Services 2005)

  • Visual Admin often lost connection

    Hi experts, I login to Visual Admin , the connection was lost about 5 seconds. If I login again, the connection will lost again. It pop-up a message "Ping time out. Conection server  is lost!" . But the J2EE is running well, all stutas in MMC is gree

  • Preview is very laggy

    Hi everyone First off my system: Intel core i7 2600@3,4 ghz 8gb ram @1333mhz GTX560@1gb win7 64bit My problem is: Both after effetcs and premiere pro are being very very laggy so that I cannot actually use the software. I'm a former Sony vegas user a

  • Utlfile error

    dear all, i m getting the below error Error message in the worker logs is:- DECLARE*ERROR at line 1: ORA-29282: invalid file ID ORA-06512: at "SYS.UTL_FILE", line 1ORA-06512: at line 41 ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE",