Authentifizierung von Benutzern gegen Active Directory Federation Services (ADFs) mit LDAP in Java (Erforderliche Klärun

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Authentifizierung von Benutzern gegen Active Directory Federation Services (ADFs) mit LDAP in Java (Erforderliche Klärun

by Anonymous » 06 Feb 2025, 06:08

Ich analysiere derzeit die Möglichkeit der Authentifizierung von Benutzern gegen ADFs mithilfe von LDAP direkt Protokoll. Ich verstehe, dass ADFs in erster Linie Protokolle wie WS-Föderation, SAML und OAuth zur Authentifizierung verwendet. Ich versuche jedoch festzustellen, ob es Szenarien gibt, in denen die direkte LDAP -Authentifizierung gegen ADFs machbar ist, auch wenn es nicht der typische oder empfohlene Ansatz ist.

Code: Select all

import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

public class LDAPAuthenticator {
public static void main(String[] args) {
// LDAP connection settings
String ldapUrl = "ldap://ldap.example.com:389";
String ldapUsername = "cn=admin,dc=example,dc=com";
String ldapPassword = "password";
String ldapBaseDn = "dc=example,dc=com";

// User credentials to authenticate
String username = "john.doe";
String password = "password";

try {
// Create an initial directory context
DirContext ctx = new InitialDirContext(getLdapEnv(ldapUrl, ldapUsername, ldapPassword));

// Authenticate the user
if (authenticateUser(ctx, ldapBaseDn, username, password)) {
System.out.println("Authentication successful!");
} else {
System.out.println("Authentication failed!");
}

// Close the directory context
ctx.close();
} catch (NamingException e) {
System.out.println("LDAP error: " + e.getMessage());
}
}

}

Top