Not able to get group name by using memberof class, getting Total groups as 0 even I am member of that group.

Not able to get group name by using memberof class, getting Total groups as 0 even I am member of that group. Through this memberof class I am trying to find full qualified name(DN) of my group.
code I have used:
//specify the LDAP search filter
               String searchFilter = "(&(objectClass=user)(CN=Username))";
               //Specify the Base for the search
               String searchBase = "";
Also I have used,
             String searchFilter = "(&(objectClass=user)(CN=Username))";
               //Specify the Base for the search
               String searchBase = "ou=ibmgroups,o=ibm.com";
But in both cases I am getting value for Total groups as 0.
Code Reference:
* memberof.java
* December 2004
* Sample JNDI application to determine what groups a user belongs to
import java.util.Hashtable;
import javax.naming.*;
import javax.naming.ldap.*;
import javax.naming.directory.*;
public class memberof     {
     public static void main (String[] args)     {
          Hashtable env = new Hashtable();
          String adminName = "CN=Administrator,CN=Users,DC=ANTIPODES,DC=COM";
          String adminPassword = "XXXXXXX";
          String ldapURL = "ldap://mydc.antipodes.com:389";
          env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
          //set security credentials, note using simple cleartext authentication
          env.put(Context.SECURITY_AUTHENTICATION,"simple");
          env.put(Context.SECURITY_PRINCIPAL,adminName);
          env.put(Context.SECURITY_CREDENTIALS,adminPassword);
          //connect to my domain controller
          env.put(Context.PROVIDER_URL,ldapURL);
          try {
               //Create the initial directory context
               LdapContext ctx = new InitialLdapContext(env,null);
               //Create the search controls          
               SearchControls searchCtls = new SearchControls();
               //Specify the search scope
               searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
               //specify the LDAP search filter
               String searchFilter = "(&(objectClass=user)(CN=Andrew Anderson))";
               //Specify the Base for the search
               String searchBase = "DC=antipodes,DC=com";
               //initialize counter to total the group members
               int totalResults = 0;
               //Specify the attributes to return
               String returnedAtts[]={"memberOf"};
               searchCtls.setReturningAttributes(returnedAtts);
               //Search for objects using the filter
               NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
               //Loop through the search results
               while (answer.hasMoreElements()) {
                    SearchResult sr = (SearchResult)answer.next();
                    System.out.println(">>>" + sr.getName());
                    //Print out the groups
                    Attributes attrs = sr.getAttributes();
                    if (attrs != null) {
                         try {
                              for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {
                                   Attribute attr = (Attribute)ae.next();
                                   System.out.println("Attribute: " + attr.getID());
                                   for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {
                                        System.out.println(" " +  totalResults + ". " +  e.next());
                         catch (NamingException e)     {
                              System.err.println("Problem listing membership: " + e);
               System.out.println("Total groups: " + totalResults);
               ctx.close();
          catch (NamingException e) {
               System.err.println("Problem searching directory: " + e);
Any help will be highly appreciated.

Not able to get group name by using memberof class, getting Total groups as 0 even I am member of that group. Through this memberof class I am trying to find full qualified name(DN) of my group.
code I have used:
//specify the LDAP search filter
               String searchFilter = "(&(objectClass=user)(CN=Username))";
               //Specify the Base for the search
               String searchBase = "";
Also I have used,
             String searchFilter = "(&(objectClass=user)(CN=Username))";
               //Specify the Base for the search
               String searchBase = "ou=ibmgroups,o=ibm.com";
But in both cases I am getting value for Total groups as 0.
Code Reference:
* memberof.java
* December 2004
* Sample JNDI application to determine what groups a user belongs to
import java.util.Hashtable;
import javax.naming.*;
import javax.naming.ldap.*;
import javax.naming.directory.*;
public class memberof     {
     public static void main (String[] args)     {
          Hashtable env = new Hashtable();
          String adminName = "CN=Administrator,CN=Users,DC=ANTIPODES,DC=COM";
          String adminPassword = "XXXXXXX";
          String ldapURL = "ldap://mydc.antipodes.com:389";
          env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
          //set security credentials, note using simple cleartext authentication
          env.put(Context.SECURITY_AUTHENTICATION,"simple");
          env.put(Context.SECURITY_PRINCIPAL,adminName);
          env.put(Context.SECURITY_CREDENTIALS,adminPassword);
          //connect to my domain controller
          env.put(Context.PROVIDER_URL,ldapURL);
          try {
               //Create the initial directory context
               LdapContext ctx = new InitialLdapContext(env,null);
               //Create the search controls          
               SearchControls searchCtls = new SearchControls();
               //Specify the search scope
               searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
               //specify the LDAP search filter
               String searchFilter = "(&(objectClass=user)(CN=Andrew Anderson))";
               //Specify the Base for the search
               String searchBase = "DC=antipodes,DC=com";
               //initialize counter to total the group members
               int totalResults = 0;
               //Specify the attributes to return
               String returnedAtts[]={"memberOf"};
               searchCtls.setReturningAttributes(returnedAtts);
               //Search for objects using the filter
               NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
               //Loop through the search results
               while (answer.hasMoreElements()) {
                    SearchResult sr = (SearchResult)answer.next();
                    System.out.println(">>>" + sr.getName());
                    //Print out the groups
                    Attributes attrs = sr.getAttributes();
                    if (attrs != null) {
                         try {
                              for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {
                                   Attribute attr = (Attribute)ae.next();
                                   System.out.println("Attribute: " + attr.getID());
                                   for (NamingEnumeration e = attr.getAll();e.hasMore();totalResults++) {
                                        System.out.println(" " +  totalResults + ". " +  e.next());
                         catch (NamingException e)     {
                              System.err.println("Problem listing membership: " + e);
               System.out.println("Total groups: " + totalResults);
               ctx.close();
          catch (NamingException e) {
               System.err.println("Problem searching directory: " + e);
Any help will be highly appreciated.

Similar Messages

  • Not able to edit event names in iCal

    Since upgrading to Snow Leopard, I am not able to edit event names in iCal once they are created. I am able to edit all other items in the event, but not name. I have tried double clicking, using the inspector, etc. to no avail. Any ideas?

    I tried getting rid of duplicates in FontBook. I tried deleteing the iCal.plist file and restarting my mac. Nothing works. I can not edit any entry in any way except to drag it to a new place. I also can't open iCal Preferences. I have iCal 4.0.1 - is that the current version?

  • I am not able to shutdown the database by using stopsap

    Dear all,
    As mentioned in the subject "I am not able to shutdown the database by using stopsap". I am getting the following errors:
    exec(): 0509-036 Cannot load program oracle<SID> because of the following errors:
            0509-150   Dependent module libjox9.a(shr.o) could not be loaded.      
            0509-022 Cannot load module libjox9.a(shr.o).                          
            0509-026 System error: A file or directory in the path name does not exist
    R3 is terminated correctly by using the command stopsap and also I am able to shutdown the database normally by using the SQL command.
    Thanks for your cooperation.
    Maher

    Thank you Nick for your care.
    I will test start/stop manually later; because the system is active and used by the users for testing purpose (not production).
    Yes, LIBPATH is the same for both users.
    The ownership/permisssion for the both files is
    -rwxr-xr-x   1 <SID>adm   sapsys    stopdb
    -rwxr-xr-x   1 <SID>adm   sapsys    startdb
    I compared with production, it seems ok.
    I started DBCheck by using the transaction DB13 and also it failed due to same errors.
    Job started
    Step 001 started (program RSDBAJOB, variant &0000000000272, user name ****)
    No application server found on database host
    Execute logical command BRCONNECT On host *******
    Parameters: -u / -c -f check
    BR801I BRCONNECT 6.20 (113)
    exec(): 0509-036 Cannot load program oracle<SID>because of the following errors:
    #0509-150   Dependent module libjox9.a(shr.o) could not be loaded.
    #0509-022 Cannot load module libjox9.a(shr.o).
    #0509-026 System error: A file or directory in the path name does not exist.
    BR805I Start of BRCONNECT processing: cdnybrme.chk 2004-08-11 08.27.04
    exec(): 0509-036 Cannot load program oracle<SID> because of the following errors:
    #0509-150   Dependent module libjox9.a(shr.o) could not be loaded.
    #0509-022 Cannot load module libjox9.a(shr.o).
    #0509-026 System error: A file or directory in the path name does not exist.
    BR280I Time stamp 2004-08-11 08.27.07
    BR301E SQL error -12547 at location db_connect-2
    ORA-12547: TNS:lost contact
    BR310E Connect to database instance <SID> failed
    exec(): 0509-036 Cannot load program oracle<SID> because of the following errors:
    #0509-150   Dependent module libjox9.a(shr.o) could not be loaded.
    #0509-022 Cannot load module libjox9.a(shr.o).
    #0509-026 System error: A file or directory in the path name does not exist.
    BR280I Time stamp 2004-08-11 08.27.07
    BR301E SQL error -12547 at location thr_db_connect-4
    ORA-12547: TNS:lost contact
    BR310E Connect to database instance <SID> failed
    BR806I End of BRCONNECT processing: cdnybrme.chk 2004-08-11 08.27.07
    BR280I Time stamp 2004-08-11 08.27.07
    BR804I BRCONNECT terminated with errors
    External program terminated with exit code 3
    BRCONNECT returned error status E
    Job finished
    Do you think that we need to rebuild the Oracle Software ?
    Thank in advance for your cooperation.
    Maher.
    Message was edited by: Maher M.

  • I had switches off my iPhone 5 at around 20 percent battery next morning I was not able to switch it on. I tried to get it charged but it didn't showed any sign of charging even when plugged in for about 2 hours. I had to take it to apple care centre

    I had switches off my iPhone 5 at around 20 percent battery next morning I was not able to switch it on. I tried to get it charged but it didn't showed any sign of charging even when plugged in for about 2 hours. I had to take it to apple care centre but they refused to repair it after confirming the problem with the device as it was out of warranty and asked me to get it replaced for INR 22500. I got it repaired outside but after that also if I switch it off in the same situation it again happens and I have to take it for repair it has happened 3 times after that. Is it a inherent problem in iPhone that it uses battery even when switched off and if in that case battery drain out then refuse to get charged because this is the scenario i have experienced every time?

    Apple told you it was unrepairable.... You had it serviced by an unauthorized party. It's now no longer eligible for out of warranty replacement by Apple.
    There's really nothing else we can say about it. Find a competent 3rd party repair shop or buy a new one.

  • After system restore ,we are not able to activate the windows,while login to systems getting an error 0x800700B7

    after system restore ,we are not able to activate the windows, while login to systems getting an error 0x800700B7
    Cont-8096688758

    hi Jain,
    you may need to check the transfer structures,
    right click infosource and 'change', click 'comm.structure'/expand,
    click 'transfer', move the 0BASE_UOM from left to right side,
    or if you wont use the comm structure anymore, you can right click infosource and 'delete comm structure'
    hope this helps.

  • I was charged no my credit card for the app store and i am not able to login, i tried to use the forget password options but it isnt going through

    i was charged no my credit card for the app store registeration and i am not able to login, i tried to use the forget password options but it isnt going through
    Apple id : [email protected]

    If the old ID is yours, and if your current ID was created by editing the details of this old ID (rather than being an entirely new ID), go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • Not able to spy objects in ie9 using coded UI Test Builder Spy, giving exception -Interface not registered(Exception from HRESULT:0X....

    Not able to spy objects in ie9 using coded UI Test Builder Spy, giving exception - "Interface not registered(Exception from HRESULT:0X...."
    I am not able to capture any objects of my web application using coded ui recorder. Even though it is a simple html page, coded ui is showing a message  -"Interface not registered(Exception from HRESULT:0X...."
    Please give me solution , why this is hapening. I am having problem with object identification. Even I am not able to identify any object in google.com.
    swapnanil sengupta

    TechnologyName is displaying as "MSAA" . But my application is a Webapplication.If I try to spy the google .com's search field then also TechnologyName is displaying as "MSAA". Is it any configuration issue of vsts codedui.
    swapnanil sengupta

  • Hi iam using iphone 5s which is locked to EE carrer. I am not able to make a conference call using this phone in india

    Hi iam using iphone 5s which is locked to EE carrer. I am not able to make a conference call using this phone in india

    then call EE if they are your carrier

  • Did not know simple things such as removing hyphen from phone numbers will be so complicated. How do i remove the hyphen from stored phone numbers since i am not able to make a phone call using VOIP. Everytime i make a phone call i have to type the number

    Did not know simple things such as removing hyphen from phone numbers will be so complicated. How do i remove the hyphen from stored phone numbers since i am not able to make a phone call using MobileVOIP. Everytime i make a phone call i have to type the number.

    Go into your contacts and edit them.

  • I am not able to upload all the contacts into icloud and get into my new iphone 6

    Hi I am trying to sync all the contacts in my old iphone 4 to iclud.
    and so not able to sync only my contacts i think i got all my photos synced.
    can any help me in that.

    Hi Kinnera2740,
    On the old phone go into Settings > Mail, Contacts, Calendars.  Are there any email accounts listed here?  Such as Google, Yahoo, Hotmail, etc?
    If so, tap on each of them and check the 'Contacts' option.  If it is turned on, this means that contact syncing is enabled for that account and that your contacts may already be synced to that mail account.
    Also check Settings > iCloud and look for the 'Contacts' option.  Is it enabled?  If so, then it is possible that some contacts could be synced to your iCloud account as well.  You can check to see which contacts are in which account by going to the Contacts app on your old phone and pressing the 'Groups' button in the top left corner.  You may see several groups here.  Uncheck all groups and then check each group one at a time to check and see how many contacts are synced to each account.  You may need to add the same mail accounts to your new phone and enable contact syncing to have the contacts from the mail servers sync down to the new phone. 

  • Hello I am not able to published to the web using an FTP the test has a negative response  I do not know what is required in Directory/path Protocol and port

    Hello I am not able to published to the web using an FTP the test has a negative response  I do not know what is required in Directory/path Protocol and port

    If you use FTP then ftp is the protocol and 21 is the port.
    Your webhoster will tell you what path to use.
    You probably can read it in the FAQ/Help/Support pages where you host your website.
    All difficult words are explained in manuals, dictionaries or wikis.

  • I am not able to update newer version on my iphone. Getting error An unknown error occurred (-9808)., I am not able to update newer version on my iphone. Getting error An unknown error occurred (-9808).

    I am not able to update newer version on my iphone. Getting error An unknown error occurred (-9808). PLease provide solution for this. I have tried connection setting all in existing discussions. Still facing issues with update iOS.

    Hi there,
    I would recommend taking a look at the troubleshooting found in the article below.
    iTunes Store: "An unknown error occurred (-9808)"
    http://support.apple.com/kb/ts2753
    -Griff W.

  • Why is Siri not able to learn new names?

    I have a refurbished fifth generation iPod Touch that was recently sent to me as a replacement for my new fifth generation iPod Touch that was sent in for repair for a broken microphone.  Today, I tried to "teach" Siri to say my name properly and the message I got back was, "Sorry.  I am not able to learn new names right now."  Is there something I can do to fix this? 

    Okay.  Thank you.  It is still not allowing me to "teach" it to say my name.  I never had this issue with my other iPod Touch.  I will let you know if this problem persists.

  • I am not able to login to i cloud using my apple id

    I am not able to login to i cloud using my apple id.

    That's too bad.  Try entering the correct login credentials.

  • HT4623 am not able to download any paid application using ma debit card.... wat can be the problem???

    am not able to download any paid application using ma debit card.... wat can be the problem???

    rahul nair wrote:
    am not able to download any paid application using ma debit card....
    Debit cards are no longer accepted.

Maybe you are looking for