tejal bilan

Greenhorn
+ Follow
since Dec 05, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tejal bilan

hi all
I need to write a program to get system registry information.
i have no idean how to go abt this. I have researched this
and seems like I need to use JNIWRAPPER class.
But this is confusing since I read it involves DLLs...I am not so familiar with this...
where do I start with this..does anyone have some sample code
i hope someone can help
regards
tejal
20 years ago
Hi michael
I have changed my name to an appropiate one.
Next time I will remember to indent code.
Thank u
Regards
tejal
20 years ago
hi all
i have the connection to LDAP goin but i am struggling with getting info out of it.
in ldap:
there is an OU=Roles, within that there are 10 roles(cn=role1), within each role, I want to get values for attribute 'member assignment'.
so i want the cn of the 10 roles and in each role their memberAssignments.
i am quite stuck..i need big help.
so any help is appreciated
thanx in advance
scarlet
my code so far:

[ December 23, 2003: Message edited by: Michael Ernest ]
20 years ago
Hi Philip
Thank you for your response.
I have tried your suggested code, but got myself abit stuck with this line:
String base = "DC=sasol,DC=com";
String filter = "CN=SAPPortal-Sec-Prod-Admin,OU=SAPPortal
Groups,OU=Groups,OU=Core,DC=sasol,DC=com";

NamingEnumeration results = dctx.search(base, filter, ctls);
I can not continue with the while loop because results is null.
The search method takes a (name, string, searchControl)
I know that the base value is right, and my string value points to the group that has the attributes "member" which I want.
Please can you help further.
I have played around with it for some time and was very unsuccessful. The error I get :

javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name 'DC=sasol,DC=com'
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.searchAux(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(Unknown source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(Unknown Source)
at javax.naming.directory.InitialDirContext.search(Unknown Source)
at com.sasol.iview.LDAPLookup.main(LDAPLookup.java:34)

source code:
public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://ldapSasol.sasol.com:389");
env.put(Context.SECURITY_PRINCIPAL,("uid"));
env.put(Context.SECURITY_CREDENTIALS, "password");
String base = "DC=sasol,DC=com";
String filter = "CN=SAPPortal-Sec-Prod-Admin,OU=SAPPortal Groups,OU=Groups,OU=Core,DC=sasol,DC=com";
try {
DirContext dctx = new InitialDirContext(env);
//String[] attrIDs = {"member"};
String[] attrIDs = {"member"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(attrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration results = dctx.search(base, filter, ctls);
//Attributes attrs1 = dctx.getAttributes("CN=SAPPortal-Sec-Prod-Admin,OU=SAPPortal Groups,OU=Groups,OU=Core,DC=sasol,DC=com");
//System.out.println("val:" + attrs1.get("cn").get());
dctx.close();
StringBuffer sb = new StringBuffer();
while (results.hasMore()) {
SearchResult res = (SearchResult) results.next();
Attributes attrs = res.getAttributes();
if (results.hasMore())
sb.append(attrs.get("member").toString().substring(4) + ",");
else
sb.append(attrs.get("member").toString().substring(4));
}

System.out.println(sb.toString());
} catch (NamingException e) {
e.printStackTrace();
}
} //end main
20 years ago
Hi All
I have connected to LDAP and have abit of trouble getting certain data out.
for example: In the LDAP browsing tool..a groupA has certain attributes and their values for example:
cn groupA
sAMAccountName aaa
member CN=Cilliers\, Maggie, OU=Users ...
member CN=James\, Kai, OU=Users ...
member CN=Henin\, Sven, OU=Users ...
How do I get all the members in groupA? Please give me example code to do this.
A bit of my code:
//***************************************************
DirContext ctx = new InitialDirContext(env);
// Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("CN=groupA,OU=GroupsA,OU=Groups,OU=Core,DC=xx,DC=com");
//getting the attributes value
System.out.println("member: " + attrs.get("member").get());
//******************************************************
I have tried to use NaminEnumeration..but was not very successful.
NamingEnumeration xx = attrs.get("member").getAll();
while(xx.hasMore()){
System.out.println(xx.??); //It has no method to get a value
}
Need urgent help
thanx in advance
Scarlet
20 years ago