java - How do I get all the memberOf Attribute assign to a particular user in LDAP -
i have created application uses ldap authentication. need find out group name in user assign to. there way find out that. have written code somehow return 1 group name randomly.
below code memberof users.
private class userattributesmapper implements attributesmapper { @override public object mapfromattributes(attributes attributes) throws namingexception { ldapuser user = new ldapuser(); user.setcn((string)attributes.get("cn").get()); user.setmemberof((string)attributes.get("memberof").get()); /*string member = (string)attributes.get("memberof").get(); int length = attributes.get("memberof").size(); if(member != null){ for(int = 0;i<= length; i++){ user.setmemberof(member); } }*/ //user.setmemberof(attributes.get("memberof").getid()); user.setsamaccountname((string)attributes.get("samaccountname").get()); return user; } }
this class used set attribute , return attribute user.
thanks in advanced.
it pretty easier thought. please find code below. in need enumerate memberof in loop , assign int in list, return list along other attribute.
below code.
private class userattributesmapper implements attributesmapper { @override public object mapfromattributes(attributes attributes) throws namingexception { ldapuser user = new ldapuser(); user.setcn((string)attributes.get("cn").get()); list<string> memberof = new arraylist<string>(); for(enumeration vals = attributes.get("memberof").getall(); vals.hasmoreelements();){ memberof.add((string)vals.nextelement()); } user.setmemberof(memberof); user.setsamaccountname((string)attributes.get("samaccountname").get()); user.setmail((string)attributes.get("mail").get()); return user; } }
Comments
Post a Comment