How to get the list of Group set in each Users in MS Active Directory

Hi. I would like to know if you know how to get the set group of each user in Active Directory?
We have this sample code
String INITCTX ="com.sun.jndi.ldap.LdapCtxFactory";
//String MY_HOST = "ldap://myserver/ou=dev,dc=test,dc=com,dc=ph";
String MY_HOST ="ldap://myserver.dev.test.com.ph:389/dc=dev,dc=test,dc=com,dc=ph";
String strUsername,strPassword;
try
     strUsername = Request.getParameter("username").toLowerCase().trim();
     strPassword = Request.getParameter("password").toLowerCase().trim();
     Hashtable env = new Hashtable();
     env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
     env.put(Context.PROVIDER_URL, MY_HOST);
     env.put(Context.SECURITY_AUTHENTICATION, "simple");
     env.put(Context.SECURITY_PRINCIPAL,strUsername+"@dev.lst.com.ph");
     env.put(Context.SECURITY_CREDENTIALS, strPassword);
After validating the User Name and Password the next task is to Retrieve the group list of the User.

Nope I want the log-in user to retrieve its Group where he is belong. I have this following code
strUsername = Request.getParameter("username").toLowerCase().trim()+"@dev.test.com.ph";
strPassword = Request.getParameter("password").toLowerCase().trim();
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
env.put(Context.PROVIDER_URL, MY_HOST);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL,strUsername);
env.put(Context.SECURITY_CREDENTIALS, strPassword);
// enable tracing
env.put("com.sun.naming.ldap.trace.ber", System.err);
// Create the initial context
DirContext initCtx = new InitialDirContext(env);
// Get the target context
DirContext targetCtx = (DirContext)initCtx.lookup("");
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
// Perform the search on the target context
NamingEnumeration enum = targetCtx.search("","(userPrincipalName="+strUsername+")",constraints);
javax.naming.directory.Attributes attrs;
NameClassPair item;
String[] attrIds = new String[]{"MemberOf"};
// For each answer found, get its "Groups" attribute
// If relative, resolve it relative to the target context
// If not relative, resolve it relative to the initial context
while (enum.hasMore()) {
item = (NameClassPair)enum.next();
Out.println(item);
attrs = targetCtx.getAttributes(item.getName(), attrIds);
Out.println(attrs + "<br>");
     initCtx.close();
It returns all this string :
{memberof=memberOf: CN=CMCanadaRD,OU=Groups / Teams,DC=dev,DC=test,DC=com,DC=ph, CN=iMngrCanadaRW,OU=Groups / Teams,DC=dev,DC=test,DC=com,DC=ph, CN=Domain Users,CN=Users,DC=dev,DC=test,DC=com,DC=ph, CN=Backup Operators,CN=Builtin,DC=dev,DC=test,DC=com,DC=ph, CN=Administrators,CN=Builtin,DC=dev,DC=test,DC=com,DC=ph}
How can i retrieve the Group named CMCanadaRW and CMCanadaRD on the Attribute?
Thanks

Similar Messages

  • How to get the list of roles assigned to a user in all the child systems

    how to get the list of roles assigned to a user in all the child systems from CUA SYSTEM

    Try transaction SUIM in your CUA system. Go to user, cross-system information, users by roles. If you run it wide open, you'll get all users and all roles assigned for all systems managed in your CUA.
    Krysta

  • How to get the list of application instance assigned to user

    Hi,
    I need to run the query in BI publisher to get the list of all the application instance assigned to a user in OIM 11g R2.
    Please let me know how to get this data. Also please let me know what is the table to see the list of application instance in OIM.
    Thanks

    Got this working..
    The table is APP_Instance to get the details of Application Instance present in OIM.

  • How to get the list of organization unit assigned to user

    hello All,
    i have to get the list of organization unit which is assigned to user. i mean if user ABC is assigned to 10 Org unit then how would i get those 10 sales Org? is there Any function module?
    Regards.

    hello Bruno,
    Thanks for reply...i got the Org unit with position...now i need to get territory Id / Areas related to those position's. can u help me in this regard?
    Regards

  • How to get the list of active devices in current wifi network?

    Hi All,
    I am going to a start a new Network based app. So please any one give me an idea on the below question.
    How to get the list of active devices in current wifi network?

    Nope I want the log-in user to retrieve its Group where he is belong. I have this following code
    strUsername = Request.getParameter("username").toLowerCase().trim()+"@dev.test.com.ph";
    strPassword = Request.getParameter("password").toLowerCase().trim();
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
    env.put(Context.PROVIDER_URL, MY_HOST);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL,strUsername);
    env.put(Context.SECURITY_CREDENTIALS, strPassword);
    // enable tracing
    env.put("com.sun.naming.ldap.trace.ber", System.err);
    // Create the initial context
    DirContext initCtx = new InitialDirContext(env);
    // Get the target context
    DirContext targetCtx = (DirContext)initCtx.lookup("");
    SearchControls constraints = new SearchControls();
    constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
    // Perform the search on the target context
    NamingEnumeration enum = targetCtx.search("","(userPrincipalName="+strUsername+")",constraints);
    javax.naming.directory.Attributes attrs;
    NameClassPair item;
    String[] attrIds = new String[]{"MemberOf"};
    // For each answer found, get its "Groups" attribute
    // If relative, resolve it relative to the target context
    // If not relative, resolve it relative to the initial context
    while (enum.hasMore()) {
    item = (NameClassPair)enum.next();
    Out.println(item);
    attrs = targetCtx.getAttributes(item.getName(), attrIds);
    Out.println(attrs + "<br>");
         initCtx.close();
    It returns all this string :
    {memberof=memberOf: CN=CMCanadaRD,OU=Groups / Teams,DC=dev,DC=test,DC=com,DC=ph, CN=iMngrCanadaRW,OU=Groups / Teams,DC=dev,DC=test,DC=com,DC=ph, CN=Domain Users,CN=Users,DC=dev,DC=test,DC=com,DC=ph, CN=Backup Operators,CN=Builtin,DC=dev,DC=test,DC=com,DC=ph, CN=Administrators,CN=Builtin,DC=dev,DC=test,DC=com,DC=ph}
    How can i retrieve the Group named CMCanadaRW and CMCanadaRD on the Attribute?
    Thanks

  • How to get the list of icc profile,which Photoshop loaded?

    I am developing a automation plugin,but I do not know how to get the list of icc profile,which photoshop loaded.
    I have read the log of "getter" and "Listener",and not find the way to get the list.

    Thank you for you answer.
    I find a icc profile has a "internal name" which show in the color setting menu in photoshop and a "external name" which is the file name. And the "internal name" maybe different with "external name".
    How I can get the "internal name" from the icc profile? I do not find the information in the ICC Profile Format Specification.
    Thank you very much!

  • How to get the list of materials from Sap r/3

    Hi Experts,
    I have one doubt, here iam implementing
    HTTP TO RFC scenario.
    My doubts are------
    1. Should we create DT MT MI and all (OR) not
    2.In Request DT how the message structure wil be to get the list of materials from sap r/3 system as Response(Ex: Fields in the source structure).
    3.Or the second thing is how to get the list of materials start with some alphabate.
    Please reply me for each and every questions mentioned above. Please clarify me.
    Helpful answers wil be rewarded.
    Reagards
    khanna

    Hi Khanna,
    <i> 1. Should we create DT MT MI and all (OR) not</i>
        Yes U need to create for HTTP site...for RFC U need to import..
    <i>2.In Request DT how the message structure wil be to get the list of materials from sap r/3 system as Response(Ex: Fields in the source structure).</i>
        You create your own structres for Request and respoce.. and Map it with RFC..
    <i>3.Or the second thing is how to get the list of materials start with some alphabate.</i>
        I think it will come with acending order....
      for more help go through this link
    /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit - File to RFC
    regards,
    Ansar.

  • How to get the list of users who has access for list of tcodes.

    How to get the list of users who has access for list of tcodes.

    Go to transaction SUIM, this has a number of reports for users/authorisations
    open the Where used>Autorization Values>In Users
    and double click to execute
    in authorisation object, enter S_TCODE
    then press the "Enter Values" button
    It will offer entry boxes to put the transaction code you are interesed in.
    Then execute and the list of users with access to this transaciton code will be returned.

  • Which WSDL file to get the list of Groups present in OAM.

    Hi All,
    Can any one tell me which WSDL file is to be used to get the list of groups present in OAM from an IDXML call.
    Please provide sample IDXML call if possible.
    Thanks in advance.
    Thanks & Regards,
    Siva Pokuri.

    guys, 80% of my problem got solved.
    here is the solution list as u all have suggested and that i have checked it also.
    RSDCUBEIOBJ     - infocube list for any nav-attr 
    RSDODSOATRNAV  - DSO list for any nav-attr
    ODSOIOBJ. - DSO list for any infoobj
    but in these tables, one thing i observe is that each infocube/DSO name is repeated multiple times. why is that? from where it populate?

  • How to get the list of database Views modifying the DB tools list tables.vi

    Hi,
    I have a problem, I just started using LabVIEW and in particular the LabVIEW connectivity toolkit and I am lookig fgor suggestion regarding how to get the list of database Views modifying the DB tools list tables.vi...
    Thanks in advance,
    Michela

    Hi Michela,
    since the VI you want to modify is part of a Toolkit, I suggest you to copy the whole block diagram in a new VI and then save it in a new location.
    Place the DB List Tables.vi on a block diagram, double click on it and go to the tab "Window -> Show Block Diagram "
    Select "Edit -> Select All" to select the whole block diagram and select "Edit -> Copy"
    Open a new VI and select "Edit -> Paste"
    Save the new VI
    In this way you can modify everything you want without overwriting the Toolkits VIs.
    Hope this can help.
    Regards, 
    Andrea N.
    Systems Engineer ATE & RF - Mediterranean Region
    National Instruments Italy

  • How to get the list of Used Quotations & Non Used Quotations

    Hi MM Gurus,
    How to get the list of Used Quotations & Non Used Quotations.
    i am not talking about Open quotation ,closed quotation..
    if once i created PO through quotation it should be used quotation. i not created PO through quotation
    it s should be Non used quotation. how to get this list through when we create PO  through ME21N
    document over view. is there any opetion in Dynamic selection or somthing ..???
    Thanks in Advance..
    Anthyodaya.

    ok.

  • How to get the list of  Quotations...???

    Hi MM Gurus,
    How to get the list of Used Quotations & Non Used Quotations.
    i am not talking about Open quotation ,closed quotation..
    if once i created PO through quotation it should be used quotation. i not created PO through quotation
    it s should be Non used quotation. how to get this list through when we create PO through ME21N
    document over view. is there any opetion in Dynamic selection or somthing ..???
    Thanks in Advance..
    Anthyodaya.

    Hi Shailesh,
    Thanks for the mail...
    but the problem is different. ...i wanted a list of used quotations and not used quotations saparate list.
    because we have same vendor for same material different price .
    so when we create PO we should use Quotation only one time.
    poen RFQ and closed RFQ is different .i means RFQ not at maintained in ME47. not at received the price from vendor or not at enterd the price. ... so that is different..
    if the non used quotation will display in ME21N  document overview it should be very usefull...
    Thanks in advance.
    Anthyodaya.

  • How to get the list of component?

        How to get the list of component through java API in Adobe CQ5?

    There are probably more than a few ways, but here is a little component .jsp code that uses the jcr query api to pull out all the components and list them on a page.  If I know CQ, there might be a way to ask for a list of components another way though, maybe through another API, or possibly a .json url, I might remember reading something about that, somewhere, lol, but this at least gets you the list in a somewhat simple way.
    Code Example:
    <%@include file="/apps/psul/components/global.jsp"%>
    <%@ page import="javax.jcr.*,
                       javax.jcr.query.*"
    %>
    <%
       // Login to create an anonymous session on the default workspace
       Session session = resourceResolver.adaptTo(Session.class);
           //Declare a query for all the components in the system
           String SQL = "select * from cq:Component";
    //side note: if you want just the components in your site area, then make the query more like below...
    //  SQL = "select * from cq:Component where jcr:path like '/apps/yoursitename/%'";
           QueryManager qm = session.getWorkspace().getQueryManager();
           Query query = qm.createQuery(SQL, Query.SQL);
           QueryResult result = query.execute();
           NodeIterator nodes = result.getNodes();
           while (nodes.hasNext()) {
               Node node = (Node)nodes.next();
               %>
                    <p><%=node.getName() %> (<b><%=node.getPath() %></b>)</p>
    <%     } %>

  • How to get the list of documents

    Hi everyone
    Can anyone help me How to get the list of documents residing in a folder of KM repository of SAP Netweaver using a simple java program
    Thanks in ADV.
    Rupesh Khemka

    Hi Rupesh,
    I have written the code for you and it works with WebDynpro, no seperate java program is required.
    Just try to paste it in your application code and run it.
    try{
         // Will check the user athentication for EP
                    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
         IUser sapUser = wdClientUser.getSAPUser(); 
         com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
         ResourceContext context = new ResourceContext(ep5User);
                    // The path in which your folder resides
         RID rid1 =RID.getRID("/documents/Public Documents/SCAP/");
         IResourceFactory factory1 = ResourceFactory.getInstance();
         ICollection icollection = (ICollection)factory1.getResource(rid1, context);
         IResourceList resourcelist = icollection.getChildren();
         int size1 = resourcelist.size();
         for(int s=0; s<listOfDocuments.getLength(); s++){
              IResource resource = resourcelist.get(i);
              InputStream input = new InputStream();
              input = resource.getContent().getInputStream();
    }catch(Exception e){
         e.getMessage();
    Once you get the InputStream everything else is possible....
    This will surely help you in reading the documents from KM.
    Regards,
    Rekha Malavathu

  • How to get the list of site collections in wss 2.0 and wss 3.0

    Hi,
    How to get the list of site collections in wss 2.0 and wss 3.0
    Please provide related articles to me
    Thanks in advance

    Use 11 for wss 2.0 and 12 for wss 3.0
    Go to :\Program Files\Common Files\Microsoft Shared\web server extensions\11\BIN\”
    stsadm.exe -o enumsites -url <root url>
    to get the list  of site collections and 
    stsadm.exe -o enumsubwebs -url <root url>
    to get the list of sub sites.
    http://support.microsoft.com/kb/832807
    http://ServerName/_layouts/1033/Siteusrs.aspx to manage permissions

Maybe you are looking for

  • How to Use My TV screen as a Computer Screen

    Hi everyone, I have a 24" Intel IMAC, 1 year old. Great computer! I saw in some other posts that this is possible but I didn't quite understand what I need to do. I would like to use my TV screen as a computer screen, so I can watch things like my su

  • Extract DDL for all objects separately !

    Hi All I have a huge DB having 3000 tables (having indexes,triggers,synonym), 1200 functions/procedures, 1000 views etc. I need to extract only metadata and put into a version control repository. I need to extract all objects (tables,procs,functions,

  • Where to get more information about CRM?

    Hi all, I want to learn CRM, now i am BW Consultant,i know ABAP. What else i should know to learn CRM.How soon can i learn this.Please help me in this regard Thanks in advance Regards N.Prasad Babu Message was edited by: John Burton

  • AEBS with an External Harddrive as a FTP Server

    Sorry if this has been answered already so fill free to point me in the right direction if so. Here is what I'd like to do; I currently have a WD harddrive plugged in to my AEBS, I'd like to use the harddrive as a FTP server for various reasons. I'd

  • Different column views for different mailboxes?

    Is it possible to view different columns for different mailboxes? Normally, the "Sent" mailbox displays only "To," not "From;" and the other mailboxes display only "From" and not "To." That's fine. But I have another mailbox I've created where I've s