The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> LDAP Programming
|
Using Novels LDAP unable to add leaf that is not a User
Discuss Using Novels LDAP unable to add leaf that is not a User in the LDAP Programming forum on Dev Shed. Using Novels LDAP unable to add leaf that is not a User LDAP Programming forum discussing Lightweight Directory Access Protocol information and techniques. LDAP is used to allow applications to access directory information from a server.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 27th, 2009, 03:36 PM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 2
Time spent in forums: 1 h 21 m 3 sec
Reputation Power: 0
|
|
|
Using Novels LDAP unable to add leaf that is not a User
Off the Applications container we have stored our Actions and our Application Roles. We are building a new application to allow us to programatically add the role privileges into the LDAP.
I am able to add my actions (an ou entry), but not the final leaf off my actions (a cn entry).
My java code for adding the action (node prior to the role) is:
// This works fine
String newfpRoleDn = preFix + "=" + fpRole + "," + fpRoleDn;
ctx = ldapSearcher.getDirContext();
BasicAttributes attrs = null;
Attribute attr = null;
attrs = new BasicAttributes();
attr = new BasicAttribute(preFix, fpRole);
attrs.put(attr);
attr = new BasicAttribute("objectClass", "organizationalUnit");
attrs.put(attr);
ctx.createSubcontext(newfpRoleDn, attrs);
ctx.close();
My java code for adding the role is something like this:
// this is not working
BasicAttributes myAttrs = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
oc.add("top");
oc.add("organizationalRole");
myAttrs.put(oc);
myAttrs.put("cn",newRoleDn);
// When I use bind I get the error:
// [LDAP: error code 17 - Undefined Attribute Type]; remaining name 'ou=ReportAdministrator_EVENSTEVENOLD,ou=DHFSDCFSdWAccess,ou=dWisacwis,ou=Applications,ou='
ctx.bind(roleDn, newRoleDn, myAttrs);
// When I use the createSubcontext I get the error:
// [LDAP: error code 19 - NDS error: syntax violation (-613)]; remaining name 'cn=DHFSDCFSdWReportAdministrator_VVVVEEEEEODS,ou=Re ...
ctx.createSubcontext(newRoleDn, myAttrs);
ctx.close();
I can add organizations, I can add individuals, I can add attributes to organizations or individuals. I can add actions, but I am not able to add an Application Role.
Can someone help me please? Every example I see is adding a person. Not all adds are people.
Thanks
|

January 28th, 2009, 01:45 PM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 2
Time spent in forums: 1 h 21 m 3 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by sharvancik Off the Applications container we have stored our Actions and our Application Roles. We are building a new application to allow us to programatically add the role privileges into the LDAP.
I am able to add my actions (an ou entry), but not the final leaf off my actions (a cn entry).
My java code for adding the action (node prior to the role) is:
// This works fine
String newfpRoleDn = preFix + "=" + fpRole + "," + fpRoleDn;
ctx = ldapSearcher.getDirContext();
BasicAttributes attrs = null;
Attribute attr = null;
attrs = new BasicAttributes();
attr = new BasicAttribute(preFix, fpRole);
attrs.put(attr);
attr = new BasicAttribute("objectClass", "organizationalUnit");
attrs.put(attr);
ctx.createSubcontext(newfpRoleDn, attrs);
ctx.close();
My java code for adding the role is something like this:
// this is not working
BasicAttributes myAttrs = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
oc.add("top");
oc.add("organizationalRole");
myAttrs.put(oc);
myAttrs.put("cn",newRoleDn);
// When I use bind I get the error:
// [LDAP: error code 17 - Undefined Attribute Type]; remaining name 'ou=ReportAdministrator_EVENSTEVENOLD,ou=DHFSDCFSdWAccess,ou=dWisacwis,ou=Applications,ou='
ctx.bind(roleDn, newRoleDn, myAttrs);
// When I use the createSubcontext I get the error:
// [LDAP: error code 19 - NDS error: syntax violation (-613)]; remaining name 'cn=DHFSDCFSdWReportAdministrator_VVVVEEEEEODS,ou=Re ...
ctx.createSubcontext(newRoleDn, myAttrs);
ctx.close();
I can add organizations, I can add individuals, I can add attributes to organizations or individuals. I can add actions, but I am not able to add an Application Role.
Can someone help me please? Every example I see is adding a person. Not all adds are people.
Thanks |
Should be able to use the
ctx.createSubcontext(newRoleDn, myAttrs);
but remove the line prior to it
myAttrs.put("cn",newRoleDn);
and it indeed works!!!!!
|

January 28th, 2009, 04:44 PM
|
|
Contributing User
|
|
Join Date: Jan 2009
Location: Charlotte, NC
Posts: 111
  
Time spent in forums: 22 h 18 m
Reputation Power: 8
|
|
|
I'm not a developer but I know LDAP pretty well. All entries added to LDAP are done the same, you build and LDIF formatted entry and then import it into the Directory server.
My java code for adding the action (node prior to the role) is:
// This works fine
String newfpRoleDn = preFix + "=" + fpRole + "," + fpRoleDn;
ctx = ldapSearcher.getDirContext();
BasicAttributes attrs = null;
Attribute attr = null;
attrs = new BasicAttributes();
attr = new BasicAttribute(preFix, fpRole);
attrs.put(attr);
attr = new BasicAttribute("objectClass", "organizationalUnit");
attrs.put(attr);
ctx.createSubcontext(newfpRoleDn, attrs);
ctx.close();
Now based on your code for adding the ACTION, this is what your variables mean
preFix=ou
fpRole=<name of Action>
fpRoleDn=<ldap base you want to add Action to>
BasicAttribute Objectclass=organizationalUnit
This will build an LDIF entry like;
dn: ou=MyAction,dc=MyDomain,dc=com
objectclass: organizationalUnit
ou: MyAction
So to add a ROLE (cn=) will be the same code different vaiable values
preFix=cn
fpRole=<name of Role>
fpRoleDn=<ldap base you want to add Role to which is now ou=MyAction,dc=MyDomain,dc=com>
BasicAttribute Objectclass=organizationalRole
This will now build an LDIF entry like;
dn: cn=Myrole,ou=MyAction,dc=MyDomain,dc=com
objectclass: organizationalRole
cn: Myrole
NOTE: objectclass=organizationalRole may have other REQUIRED attributes.
Objectclass=organizationalUnit only requires attributes (objectclass, ou)
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|