Skip to content

Commit

Permalink
add new test - IsEnabled that checks whether the user is enabled/disa…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
gabibeyo committed Apr 11, 2019
1 parent a0cf9fa commit 31ecdcb
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions startingkit/ddckit/src/main/java/com/imperva/ddc/kit/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public static void main(String[] args) {
useCase9();

useCase10();
}

isEnabled();
}

private static void useCase1() {
Endpoint endpoint = createEndpoint();
Expand Down Expand Up @@ -322,12 +323,16 @@ private static void useCase10() {


private static Endpoint createEndpoint() {
return createEndpoint("<YOUR IP>",389,"<DOMAIN>\\<NAME>","<YOUR PASS>",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("<YOUR IP>");
endpoint.setPassword("<YOUR PASS>");
endpoint.setUserAccountName("<DOMAIN>\\<NAME>"); //* 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);
Expand All @@ -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,"<domain\\administrator>","<pass>",false);
Endpoint endpointToCheckIfEnabled = createEndpoint("<10.10.10.10>",389,"domain\\userToCheckIfEnabled","<pass>",false);
ConnectionResponse connectionResponse = DirectoryConnectorService.authenticate(endpointAdmin,true, endpointToCheckIfEnabled);
boolean succeeded = !connectionResponse.isError();
System.out.println("Is Enabled - User is Authenticated and Enabled: " + succeeded);
}
}

0 comments on commit 31ecdcb

Please sign in to comment.