[jcifs] Help!!

Thomas Bley thomas.bley at simple-groupware.de
Tue Aug 29 16:22:44 GMT 2006


Hello,

When using Active Directory you might use LDAP queries for getting 
memberships ?
e.g. I'm using this code to get the username out of a SID:

        Hashtable env = new Hashtable();
        
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.SECURITY_AUTHENTICATION,"simple");
       
        if (ldap_domain.length()>0) username = domain+"\\\\"+ldap_user;
        env.put(Context.SECURITY_PRINCIPAL,ldap_user);
        env.put(Context.SECURITY_CREDENTIALS,ldap_pass);
        if (ldap_useSSL) {
            env.put(Context.SECURITY_PROTOCOL, "ssl");
            env.put(Context.PROVIDER_URL,"ldap://"+ldap_server+":636");
        } else {
            env.put(Context.PROVIDER_URL,"ldap://"+ldap_server+":389");
        }
        LdapContext ctx = new InitialLdapContext(env,null);
        SearchControls searchCtls = new SearchControls();
        String returnedAtts[]={"cn","objectClass"};
        searchCtls.setReturningAttributes(returnedAtts);
        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        NamingEnumeration answer = ctx.search(ldap_dc, 
"(objectSID="+sid+")", searchCtls);
        if (answer.hasMoreElements()) {
            SearchResult sr = (SearchResult)answer.next();
            Attributes attrs = sr.getAttributes();
            if (sr.getName().length()>0 && attrs != null &&
                attrs.get("objectClass")!=null && attrs.get("cn")!=null) {
                return "("+attrs.get("objectClass").get(1)+") 
"+attrs.get("cn").get();
            }
        } else return sid;
        ctx.close();

bye
Thomas



richard.evans at thoughtbreak.com wrote:
> Thanks Mike,
> Does that mean we have to resign ourself to ..
>  
> "JCIFS extension netUserGetGroups does not work if the target user is 
> a member of many groups "
>  
> .. or is there a way around the problem? I am not familiar with teh 
> underlying facility but would have hoped for some kind of iterative 
> call to retrieve groups in page-loads may be an option.
>  
> Regards,
> Richard
>  
>
> +44(0)7985 437 517
> richard.evans at thoughtbreak.com <mailto:richard.evans at thoughtbreak.com>
>
>
> ----- Original Message ----
> From: Michael B Allen <mba2000 at ioplex.com>
> To: richard.evans at thoughtbreak.com
> Cc: bharati_t at thbs.com; jcifs at lists.samba.org
> Sent: Tuesday, August 29, 2006 4:02:56 PM
> Subject: Re: [jcifs] Help!!
>
> RAPs are limited to 64K. Take a look at Jarapac.
>
> On Tue, 29 Aug 2006 07:52:39 -0700 (PDT)
> <richard.evans at thoughtbreak.com> wrote:
>
> > Hello Mike,
> > It is in the RAP package of the JCIFS Extensions 
> http://sourceforge.net/projects/jcifs-ext/
> > (I have the same problem!)
> > Regards,
> > Richard
> >  
> >
> > +44(0)7985 437 517
> > richard.evans at thoughtbreak.com
> >
> >
> >
> >
> > ----- Original Message ----
> > From: Michael B Allen <mba2000 at ioplex.com>
> > To: Bharati <bharati_t at thbs.com>
> > Cc: jcifs at lists.samba.org
> > Sent: Tuesday, August 29, 2006 3:18:57 PM
> > Subject: Re: [jcifs] Help!!
> >
> >
> > On Tue, 29 Aug 2006 18:17:52 +0530
> > "Bharati" <bharati_t at thbs.com> wrote:
> >
> > > Hi there,
> > >
> > > Am getting the Error MORE_DATA_AVAILABLE while using netUserGetGroups.
> > > Am unable to change the buffer size.Can anyone help me out of this?
> > > Please tell me where can i change the buffer size and how can i 
> get this error removed...
> >
> > JCIFS doesn't have a netUserGetGroups method. What package are you 
> using?
> >
> > Mike
> >
> > --
> > Michael B Allen
> > PHP Active Directory SSO
> > http://www.ioplex.com/
>
>
> -- 
> Michael B Allen
> PHP Active Directory SSO
> http://www.ioplex.com/
>



More information about the jcifs mailing list