Wenn ich das in einfachem Java 17 mache, dann erledigt dieser Teil des Codes die Aufgabe.
Code: Select all
public static void createUser(DirContext ctx) throws Exception {
String userCn = "Piet Jansen";
String userSam = "piet";
String userDn = "CN=" + userCn + ",OU=_TEMP_TEST_MuleSoft,DC=corp,DC=example,DC=lan";
String password = "Welcome123!Testsecret";
Attributes attrs = new BasicAttributes(true);
Attribute objClass = new BasicAttribute("objectClass");
objClass.add("top");
objClass.add("person");
objClass.add("organizationalPerson");
objClass.add("user");
attrs.put(objClass);
attrs.put("cn", userCn);
attrs.put("sAMAccountName", userSam);
attrs.put("userPrincipalName", "[email protected]");
attrs.put("displayName", userCn);
attrs.put("givenName", userSam);
attrs.put("sn", "Jansen");
// 🔐 simulation of the unicodePwd attribute
String quotedPwd = "\"" + password + "\"";
byte[] pwdBytes = quotedPwd.getBytes(StandardCharsets.UTF_16LE);
attrs.put("unicodePwd", pwdBytes);
attrs.put("userAccountControl", "544"); // NORMAL_ACCOUNT + PASSWD_NOTREQD
ctx.createSubcontext(userDn, attrs);
System.out.println("User created: " + userDn);
}
Aber ich möchte dafür den Mulesoft LDAP(S)-Connector verwenden.
Wenn meine Dataweave-Nutzlast für den Mulesoft LDAP-Connector so ist, funktioniert es, das Konto wird in AD erstellt, aber ohne das Standardkennwort, wie Sie sehen.
Code: Select all
{
"cn": "Piet Jansen",
"sAMAccountName": "Piet",
"userPrincipalName": "[email protected]",
"objectClass": ["top", "person", "organizationalPerson", "user"],
"dn": "CN=Piet Jansen,OU=_TEMP_TEST_MuleSoft,DC=corp,DC=example,DC=lan",
"userAccountControl": "544", // NORMAL_ACCOUNT + PASSWD_NOTREQD
"givenName": "Piet",
"sn":"Jansen",
"displayName": "Piet Jansen"
}
Code: Select all
{
"cn": "Piet Jansen",
"sAMAccountName": "Piet",
"userPrincipalName": "[email protected]",
"objectClass": ["top", "person", "organizationalPerson", "user"],
"dn": "CN=Piet Jansen,OU=_TEMP_TEST_MuleSoft,DC=corp,DC=example,DC=lan",
"unicodePwd": "Welcome123!Testsecret",
"userAccountControl": "544", // NORMAL_ACCOUNT + PASSWD_NOTREQD
"givenName": "Piet",
"sn":"Jansen",
"displayName": "Piet Jansen"
}
Code: Select all
"OPERATION_NOT_SUPPORTED: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A126C, problem 5003 (WILL_NOT_PERFORM), data 0
Code: Select all
//password between double quotes as a String
"unicodePwd": '\"' ++ "Welcome123!Testsecret" ++ '\"'
//some converting to get a binary
"unicodePWD": toBase64(toBinary('\"' ++ "Welcome123!Testsecret" ++ '\"', 'UTF-16LE'))
//some other way with converting
"unicodePwd": '\"' ++ "Welcome123!Testsecret" ++ '\"' as Binary {encoding: "UTF_16LE"}
// I tried a call to a Java function also:
//MuleLdapUtil custom class look like this:
package nl.example.ldap.utils;
public class MuleLdapUtil {
public static byte[] getPW() {
String quotedPwd = "\"" + "Welcome123!Testsecret" + "\"";
byte[] pwdBytes = quotedPwd.getBytes(StandardCharsets.UTF_16LE);
return pwdBytes;
}
}
//then import the class in dataweave
import java!nl::example::ldap::utils::MuleLdapUtil
//and use the attribute in the payload.
uniCodePwd: (MuleLdapUtil::getPW())
Mobile version