0
I am trying to remove an attribute from an AD record using Pentaho, so I have this script below. It is returning the error:
Can’t find method javax.naming.directory.InitialDirContext.modifyAttributes(javax.naming.ldap.Ldapname,number,javax.naming.directory.Basicattribute). (script#36)
36 is the last line!
Any hint for me to correct or some idea?
The code is:
var Properties = java.util.Properties;
var ArrayList = java.util.ArrayList;
var List = java.util.List;
var Context = javax.naming.Context;
var InitialContext = javax.naming.InitialContext;
var NamingEnumeration = javax.naming.NamingEnumeration;
var NamingException = javax.naming.NamingException;
var Attribute = javax.naming.directory.Attribute;
var Attributes = javax.naming.directory.Attributes;
var BasicAttribute = javax.naming.directory.BasicAttribute;
var DirContext = javax.naming.directory.DirContext;
var InitialDirContext = javax.naming.directory.InitialDirContext;
var ModificationItem = javax.naming.directory.ModificationItem;
var LdapName = javax.naming.ldap.LdapName;
var modifyAttributes = javax.naming.modifyAttributes;
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.SECURITY_AUTHENTICATION, "simple");
properties.put(Context.PROVIDER_URL, "ldap://<server>:389");
properties.put(Context.SECURITY_PRINCIPAL, "<dn do usuário de acesso>");
properties.put(Context.SECURITY_CREDENTIALS, "<senha>");
var dn = "<dn do grupo de onde quero remover o atributo>";
var usr = distinguishedName;
name = new LdapName(dn);
//context = new DirContext(new InitialDirContext(properties));
context = new InitialDirContext(properties);
attributes = new Attributes(context.getAttributes(dn));
attribute = new BasicAttribute("member", usr);
attributes.put(attribute);
item = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attribute);
context.modifyAttributes(name, item);