I have a java program that runs on the System I that updates various Active Directory Attributes with values found in our HR system.
I have been asked to do an update to the TerminalServicesProfilePath attribute, but my regular methods do not seem to be able to update or retrieve the value of this attribute.
Has anyone done this, and could you provide me a sample of how I can get this attr updated from within my Java Program? I have googled and searched, but cannot find a Java solution.
I am providing a sample of my program on how I currently update other values. I have only supplied a sample of 2 mods to reduce the source side. This Java program is called from a CLP file read loop and is executed for each active employee.
String strDN = args[0];
String parm01 = args[1];
String parm02 = args[2];
env.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials, note using simple cleartext authentication
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, adminName);
env.put(Context.SECURITY_CREDENTIALS, adminPassword);
//connect to my domain controller
env.put(Context.PROVIDER_URL, "
ldap://boedc001.kcmsd.int:389");
try
{
// Create the initial directory context
LdapContext ctx = new InitialLdapContext(env, null);
// Set Attribute values
ModificationItem[] mods = new ModificationItem[23];
mods[0] =
new ModificationItem(
DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute("department", parm01.trim() + " "));
mods[1] =
new ModificationItem(
DirContext.REPLACE_ATTRIBUTE,
new BasicAttribute(
"departmentNumber",
parm02.trim() + " "));
userName = strDN;
// Perform the update
ctx.modifyAttributes(userName, mods);
//tls.close();
ctx.close();
As an Amazon Associate we earn from qualifying purchases.