Hinzufügen des unicodePwd-Attributs zu einem neuen Active-Directory-Konto mit Mulesoft LDAP-ConnectorJava

Java-Forum
Anonymous
 Hinzufügen des unicodePwd-Attributs zu einem neuen Active-Directory-Konto mit Mulesoft LDAP-Connector

Post by Anonymous »

Ich möchte ein Konto in Active Directory (AD) mit dem LDAP Mulesoft-Connector erstellen. Ich kann dies problemlos tun, aber es funktioniert NUR, wenn ich das Benutzerkennwort (unicodePwd) nicht übermittle. Das Problem besteht also darin, wie man in Mulesoft Dataweave das richtige Format (Daten, Bytes oder was auch immer) für unicodePwd verwendet, um einen Benutzer in AD mit einem Standardkennwort zu erstellen.
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);
}
Der obige Java-Code funktioniert, wenn der richtige LDAP-Kontext (ctx) erstellt wird, aber das ist nicht das Problem. Aber es zeigt, dass die Aufgabe erledigt werden kann und der Domänencontroller mit dem SSL-Teil korrekt konfiguriert ist. Und in Java ist der vertrauenswürdige Speicher für SSL korrekt konfiguriert.
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"
}
Aber wenn ich das unicodePwd-Attribut wie folgt zur Dataweave-Nutzlast für den Mulesoft LDAP-Connector hinzufügen möchte, erhalte ich einen LDAP-Fehler.

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"
}
Dann erhalte ich einen LDAP-Fehler wie diesen:

Code: Select all

"OPERATION_NOT_SUPPORTED: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A126C, problem 5003 (WILL_NOT_PERFORM), data 0
Ich habe verschiedene Dataweave-Konfigurationen für das unicodePWD-Attribut ausprobiert, wie zum Beispiel:

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())

Keines davon funktioniert, daher ist meine Frage, was das richtige Format des unicodePwd-Attributs in der Nutzlast für den LDAP-Connector ist?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post