Getting list of all users and their group memberships from Active Directory

Hi,
I want to retrieve a list of all the users and their group memberships through JNDI from Active Directory. I am using the following code to achieve this:
==================
import javax.naming.*;
import java.util.Hashtable;
import javax.naming.directory.*;
public class GetUsersGroups{
     public static void main(String[] args){
          String[] attributeNames = {"memberOf"};
          //create an initial directory context
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
          env.put(Context.PROVIDER_URL, "ldap://172.19.1.32:389/");
          env.put(Context.SECURITY_AUTHENTICATION, "simple");
          env.put(Context.SECURITY_PRINCIPAL, "[email protected]");
          env.put(Context.SECURITY_CREDENTIALS, "p8admin");
          try {
               // Create the initial directory context
               DirContext ctx = new InitialDirContext(env);     
               //get all the users list and their group memberships
               NamingEnumeration contentsEnum = ctx.list("CN=Users,DC=filenetp8,DC=com");
               while (contentsEnum.hasMore()){
                    NameClassPair ncp = (NameClassPair) contentsEnum.next();
                    String userName = ncp.getName();
                    System.out.println("User: "+userName);
                    try{
                         System.out.println("am here....1");
                         Attributes attrs = ctx.getAttributes(userName, attributeNames); // only asked for one attribute so only one should be returned
                         System.out.println("am here....2");
                         Attribute groupsAttribute = attrs.get(attributeNames[0]); // memberOf
                         System.out.println("-----"+groupsAttribute.size());
                         if (groupsAttribute != null){
                              // memberOf is a multi valued attribute
                              for (int i=0; i<groupsAttribute.size(); i++){
                              // print out each group that user belongs to
                              System.out.println("MemberOf: "+groupsAttribute.get(i));
                    }catch(NamingException ne){
                    // ignore for now
               System.err.println("Problem encountered....0000:" + ne);
               //get all the groups list
          } catch (NamingException e) {
          System.err.println("Problem encountered 1111:" + e);
=================
The following exception gets thrown at every user entry:
User: CN=Administrator
am here....1
Problem encountered....0000:javax.naming.NamingException: [LDAP: error code 1 -
000020D6: SvcErr: DSID-03100690, problem 5012 (DIR_ERROR), data 0
]; remaining name 'CN=Administrator'
I think it gets thrown at this line in the code:
Attributes attrs = ctx.getAttributes(userName, attributeNames);
Any idea how to overcome this and where am I wrong?
Thanks in advance,
Regards.

In this sentence:
Attributes attrs = ctx.getAttributes(userName, attributeNames); // only asked for one attribute so only one should
It seems Ok when I add "CN=Users,DC=filenetp8,DC=com" after userName, just as
userName + ",CN=Users,DC=filenetp8,DC=com"
But I still have some problem with it.
Hope it will be useful for you.

Similar Messages

  • Need to get a listing of all users and their corresponding Exchange 2013 Mailbox Quotas using Powershell

    I will be changing the default quota on mailboxes soon, but there are a number of others who have "customized" quotas and I will need to identify them also.
    Charlie

    The following powershell command can get you the mailboxes that are using "custum "quota:
    Get-Mailbox -Resultsize unlimited | where-object {$_.UseDatabaseQuotaDefaults -eq $false}

  • BI Report - List all users and their assigned roles

    Hello,
    i need a report, which lists me all users and their roles.
    Which table stores this membership information about the users?
    USR or UGP does not have any values

    Hi Reynaldo,
    You can go to SE16 -> table name "AGR_USERS" and see the records for all users. Arrange them in ascending order by name and you will get the report what you have mention above.
    Download it and put it in EXCEL.
    Best Wishes.
    Kumar

  • Command to  provide list of all objects and their scripts from database

    Hi,
    How do i get the list of all objects and their scripts/source from database?
    I guess using dbms_metadata package or Toad tool we can achieve the above task
    But i do not know the steps to get the objects and their scripts.
    Im using oracle database 11g R2 11.2.0.2
    Kindly ge me the advice
    Thanks in Advance

    How do i get the list of all objects and their scripts/source from database?
    I guess using dbms_metadata package or Toad tool we can achieve the above task
    But i do not know the steps to get the objects and their scripts.
    Im using oracle database 11g R2 11.2.0.2If you want the all the metadata of whole database, then it is quiet difficult to get from DBMS_METADATA, as it is very complex because you need to gather for each object of each schema in whole database and to spool.
    http://www.orafaq.com/node/57
    I want to know, what is the use of entire database metadata, Certainly need of objects of metadata.
    or if you want to whole database, then i suggest you go for export full backup and import as impdp sqlfile option,

  • How can I list all users and their DEFAULT tablespace?

    How can I list all users and their DEFAULT tablespace?
    Peter

    Peter, the following short article that lists the most heavily used Oracle rdbms dictionay views might be of interest based on your question:
    How do I find information about a database object: table, index, constraint, view, etc… in Oracle ? http://www.jlcomp.demon.co.uk/faq/object_info.html
    HTH -- Mark D Powell --

  • Report to list all computers and their collection membership

    Hi
    I am currently working on a site where direct membership is used for collections but a need has arisen to move to AD Queries.
    I have created a simple powershell script that creates groups based on the contents of a csv file and another script which populates this with the members listed in another csv file.
    To help speed up the process is there a way to generate a report that lists ALL Computers and their Collection membership?
    The only reports I seem to find that are built in require an inputted value of either computer name of collection ID. I simply need a report that lists Computer Name is column 1 and Collection Name in column 2 for all computers and all collections.
    Many Thanks,
    Matt Thorley

    select 
    FCM.Name,
    C.Name
    from 
    dbo.v_Collection C
    join dbo.v_FullCollectionMembership FCM on C.CollectionID = FCM.CollectionID
    Thanks to Garth for original query. I just modified it :)
    Anoop C Nair (My Blog www.AnoopCNair.com)
    - Twitter @anoopmannur -
    FaceBook Forum For SCCM

  • Getting list of all users present in SIM

    Hi,
    I would like to update all the users (attributes of users) in SIM .
    Right now I am thinking to get list of all users present in SIM and get the view of each user and then update the particular attribute and chekin the view. and imp point to note here is I am having around 100,000 users present in SIM.
    I am thinking there could be a better solution than this...
    But I do not know which way can be used to accomplish the task.
    Can any one reply immediately with any thought on this.
    Thanks in advance.

    Run a bulk update actions you can easily get a list of all accountids by running select name from userobj;
    and in your field or in your input area specify the values u wanna update

  • FM to get list of all directories and files on application server..

    Hi All,
    Can anyone tel me FM to get list of all directories and files on application server..i know 'F4_DXFILENAME_TOPRECURSION'
    and '/SAPDMC/LSM_F4_SERVER_FILE' these are working too...but my requirement is when i click F4 i should get list of directories and whn i select one of these the only directory name should display.....and whn click again for 2nd text box field i want file name ...means directory name in one text box field and file name in another....plz help me out..
    helpful answers wil b awarded.
    Thanks,
    Jayshree

    Hi Jayashree
    Please check this FM, SUBST_GET_FILE_LIST. Pass the file path and file name, if it returns an entry in table FILE_LIST, then the filename and path are valid.
    Hope this helps !
    ~ Ranganath

  • List all users and their own roles.

    Hi everybody!
    I have to make a list of all sap users and their own separated roles by user. There are any transaction to do it? The SUIM transaction gives me a sap user and their own roles, but if I try with a lot users It gives me all the roles that are using those users but don't give me the roles for each one.
    Thanks a lot.
    Best regards.

    Hi Reynaldo,
    You can go to SE16 -> table name "AGR_USERS" and see the records for all users. Arrange them in ascending order by name and you will get the report what you have mention above.
    Download it and put it in EXCEL.
    Best Wishes.
    Kumar

  • Report of Users and their groups

    Hi Experts,
    Is there a way to extract all the Hyperion Planning Users and the groups they belong in Hyperion 11.1.2.1 version? I need an excel file having the users and groups.
    Thanks
    Kannan.

    Hello Kannan,
    Yes, a clean list of Users with their Groups...
    Nothing standard. Strange...
    You might see if this export has something you can use. I do not recall it from the vast amount of detail exported here. The file will be generated on the server, so you might need somebody to pick it up and give it to you.
    MaxL command
    export security_file to data_file "essbase_security_file.txt";
    The alternative is to query the Planning repository. Maybe somebody has experience with this?
    Regards,
    Philip

  • Import all users and their objects without doing full database import

    Hi Guys,
    I have a task to that involves Importing all existing users and their objects in production to the test database without doing a full database import - Please how do i do this?
    Pls i need your help urgently.

    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    I tried to import objects and data from a user from a FULL dump file. File was created with the following command:
    server is: SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 26 15:34:05 2010
    exp full=y FILE="full.dmp" log=full.log
    Now I imported:
    imp file=full.dmp log=full.log INCTYPE=SYSTEM
    imp fromuser=user1 file=full.dmp
    Results: not all the user procedures have been imported:
    SQL> select count(*) from user_procedures;
    the Original
    COUNT(*)
    134
    the current:
    select count(*) from user_procedures;
    COUNT(*)
    18
    I also tried these alternatives:
    exp tablespaces="user1_data" FILE="user1.dmp" log=user1.log
    exp LOG=user1.log TABLESPACES=user1_data FILE=user1_data.dmp
    exp LOG=user1owner.log owner=user1 FILE=user1owner.dmp
    expdp DIRECTORY=dpump_dir1 dumpfile=servdata_pump version=compatible SCHEMAS=user1
    impdp directory=data_pump_dir dumpfile=servdata_pump.dmp :
    ORA-39213: Metadata processing is not available
    SQL> execute dbms_metadata_util.load_stylesheets
    BEGIN dbms_metadata_util.load_stylesheets; END;
    ERROR at line 1:
    ORA-31609: error loading file "kualter.xsl" from file system directory
    "/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/xml/xsl"
    ORA-06512: at "SYS.DBMS_METADATA_UTIL", line 1793
    ORA-06512: at line 1
    file kualter.xsl does not exist in XE !!
    imp owner=user1 rows=n ignore=y
    imp full=y file=user1_data.dmp
    imp full=y file=full.dmp tablespaces=user1_data,user1_index rows=n ignore=y
    So, I do not understand why user1 objects are not imported:
    see this part of the first import log:
    Export file created by EXPORT:V10.02.01 via conventional path
    import done in US7ASCII character set and AL16UTF16 NCHAR character set
    import server uses WE8ISO8859P1 character set (possible charset conversion)
    . importing SYS's objects into SYS
    . importing USER1's objects into USER1
    . . importing table .........................
    why only 18 rows?
    if you have an suggestion, you are welcome, as I do not have any other idea...
    ren
    Edited by: ronpetitpatapon on May 26, 2010 12:38 PM
    Edited by: ronpetitpatapon on May 26, 2010 12:41 PM
    Edited by: ronpetitpatapon on May 26, 2010 1:03 PM

  • How to export users and their roles/responsibilities from OBIEE 11g weblogic console ? (we have nearly 8000 users)

    Hi Gurus,
    I am not an expert in the OBIEE 11g security area, we have an urgent requirement where in i need to obtain the complete list of all users along with their roles/responsibilities.Ours is a big organization and there are nearly 8000 users. Please advice if i need to write any weblogic script (WLST) or is there any other simple way for this..
    Thanks,

    If it is through Presentation Layer,Below the steps you can follow:-
    1. Open the OBIEE 11G RPD (offline/online) in Administration Tool
    2. Select the ALL/required presentation objects form your Presentation Layer and right-click.
    3. On the context menu select “Permission Report”
    4 .The Permission Report dialog displays the name and a description of the selected presentation object,
    along with a list of users/application roles and their permissions. CLick the Save button to save the permissions in CSV format.
    5.Once you saved to a CSV format, you can use that report for the quick auditing of security management.
    Below the screen shot for the same
    http://www.4shared.com/photo/h1EKYgh1/zrclip_002p5719bc78.html
    Mark if helps.
    Thanks,

  • Querying users and their resource names from SSO tables

    Hi,
    Any ideas how to query the SSO tables so that i can extract all users and which "Resource Access Information" (for Forms based applications) is assigned to each user.?
    A bit like the solution on the link below but also with a join to resource names (for Forms) that each user has.
    Querying user enabled status from SSO tables
    Thanks

    Thank you for that! I have extended this query to contain the ods.ct_uid table as follows as some users were being omitted. Also I have included a decode statement that changes the 'enabled' or 'disabled' to a 0 or 1.
    SELECT
    UPPER(cus.attrvalue) username,
    DECODE(NVL(ena.attrvalue, 'enabled'), 'enabled', 1, 'disabled', 0) enabled
    FROM
    ods.ct_orclisenabled ena,
    ods.ct_uid cus,
    ods.ct_cn ctu
    WHERE cus.entryid = ctu.entryid
    AND ena.entryid (+) = ctu.entryid

  • List all users and their OUs they belong to

    Hi,
    I would like to list all users with the OU they belong to and furthermore add an specific attribute that was added...
    I can get both information separately:
    get-aduser -SearchBase 'OU=DOMAIN,DC=mygroup,DC=re,DC=lan' | FT name
    and
    Get-ADOrganizationalUnit -SearchBase 'OU=DOMAIN,DC=mygroup,DC=re,DC=lan' -properties name,budgetanalytics | FT name,budgetanalytics
    but I'd like to get the list containing user1, its OU, its budgetanalytics
    Thanking you in advance,
    Cédric

    Thanks for your reply!
    I tried the following:
    $Users = get-aduser -SearchBase 'OU=Mes Utilisateurs,DC=itced,DC=lan' -filter '*'
    $OU = $User.distinguishedname -split ',',2 | select -last 1
    $output = @()
    Foreach($User in $Users){
    $budgetanalytics = Get-ADOrganizationalUnit -SearchBase $OU -Properties objectGUID
    $Object = New-Object PSObject                                       
    $Object | add-member Noteproperty user $user.name         
    $Object | add-member Noteproperty OU $OU                       
    $Object | add-member Noteproperty objectGUID $objectGUID       
    $output += $Object
    $output
    but I get the following
    user                                             
    OU                                              
    objectGUID                                      
    User1                                            
    OU=Mon OU,OU=Mes Utilisateurs,DC=itced,DC=lan    {Microsoft.PowerShell.Commands.Internal.Forma...
    User2                                            
    OU=Mon OU,OU=Mes Utilisateurs,DC=itced,DC=lan    {Microsoft.PowerShell.Commands.Internal.Forma...
    Why do I get "Microsoft.PowerShell.Commands.Internal.Forma..." instead of the actual objectGUID of the Organizational Unit
    Thanking you in advance

  • How to get a list of current users and their transactions code?

    SM04 and AL08 give the list, but its not comprehensive.  in sm04, we have to click the username and select sessions and then a
    new popup comes giving all transactions for the user. 
    I want a list such that each and every transaction corresponding to the user is listed at same time.

    Hi,
    Use the FM TH_LONG_USR_INFO.
    Just give parameter user as * (it means all users, other wise current user)
    It will give ALL transactions for ALL users.
    Regards,
    Amit Mittal.
    Edited by: Amit Mittal on Dec 30, 2009 1:00 PM
    Edited by: Amit Mittal on Dec 30, 2009 1:03 PM

Maybe you are looking for

  • WLC 5508 and its 8 ports

    I've three independants sites that I want to manage with the controller 5508, do I have to use three port of management? could you explain me the use of managment interface because the wlc contains 8 and I'm using the first port "1".

  • [Flash MX 2004] desactivar marco

    Alguien sabe como se puede desactivar el cuadro que sale alrededor de las acciones en flash de una p�gina. Es algo que he visto en el Internet Explorer 6 y seguramente tenga que ver con algun ActiveX. No es nada grave, pero resulta molesto tener que

  • The character when upgrade database

    hj all, i have a problem is confuse, the old oracle database, character set is UTF8, now i upgrade oracle DB from 8 to 10gr2, and my question: if i set character set in the oracle DB 10gR2 is AL32UTF8 , after import dump file from old DB into DB 10GR

  • Migrating to J2EE Platform.

    Dear Sir, We are currently using Forms based systems. Our company have decided to move to J2EE platform. In our applications, we extensively use all the forms concepts like timer, hierarchical structure, etc. Now my doubt is, do J2EE platform support

  • Can I "record" to DV tape from a DV file?

    I have this huge (23 gig) DV file of a favorite project. It's just under one hour in length. I no longer have the original source tapes, and would like a DV tape "copy" as a back-up. I thought I could just hook-up the camcorder and record away, but I