diff --git a/startingkit/ddckit/src/main/java/com/imperva/ddc/kit/Main.java b/startingkit/ddckit/src/main/java/com/imperva/ddc/kit/Main.java index 7d7d06e..59db720 100644 --- a/startingkit/ddckit/src/main/java/com/imperva/ddc/kit/Main.java +++ b/startingkit/ddckit/src/main/java/com/imperva/ddc/kit/Main.java @@ -39,8 +39,9 @@ public static void main(String[] args) { useCase9(); useCase10(); - } + isEnabled(); + } private static void useCase1() { Endpoint endpoint = createEndpoint(); @@ -322,12 +323,16 @@ private static void useCase10() { private static Endpoint createEndpoint() { + return createEndpoint("",389,"\\","",false); + } + + private static Endpoint createEndpoint(String host, int port, String userName, String pass, boolean isSecured) { Endpoint endpoint = new Endpoint(); - endpoint.setSecuredConnection(false); - endpoint.setPort(389); - endpoint.setHost(""); - endpoint.setPassword(""); - endpoint.setUserAccountName("\\"); //* You can us the user's DistinguishedName as well + endpoint.setSecuredConnection(isSecured); + endpoint.setPort(port); + endpoint.setHost(host); + endpoint.setPassword(pass); + endpoint.setUserAccountName(userName); //* You can us the user's DistinguishedName as well //*endpoint.setSecondaryPort(389); //*endpoint.setSecondaryHost("10.100.10.100"); //*endpoint.setSecuredConnectionSecondary(false); @@ -344,4 +349,12 @@ private static QueryRequest createQueryRequest(final Endpoint endpoint) { queryRequest.setTimeLimit(1000); return queryRequest; } + + private static void isEnabled() { + Endpoint endpointAdmin = createEndpoint("<10.10.10.10>",389,"","",false); + Endpoint endpointToCheckIfEnabled = createEndpoint("<10.10.10.10>",389,"domain\\userToCheckIfEnabled","",false); + ConnectionResponse connectionResponse = DirectoryConnectorService.authenticate(endpointAdmin,true, endpointToCheckIfEnabled); + boolean succeeded = !connectionResponse.isError(); + System.out.println("Is Enabled - User is Authenticated and Enabled: " + succeeded); + } }