@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
LdapDomain ldapDomain = getLdapDomain();
LdapService ldapService = getLdapService();
LdapDN organizationDN = LdapDN.fromDomainName(ldapDomain.organizationName);
LdapDN allUsersDN = organizationDN.childDN("ou", "Users");
LdapDN managerDN = organizationDN.childDN("cn", "Manager");
LdapDN groupsDN = organizationDN.childDN("ou", "Groups");
LdapDN gitUsersDN = groupsDN.childDN("cn", "Git");
// String authLdapUrl = "ldap://192.168.192.67:389/ou=Users,dc=com,dc=fathomscale?uid";
// String authLDAPBindDN = "cn=Manager,dc=com,dc=fathomscale";
// String authLDAPBindPassword = "adminsecret";
// String requireLdapGroup = "cn=Git,ou=Groups,dc=com,dc=fathomscale";
int port = 389;
List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(ldapService.getTags(), port);
EndpointInfo ldapEndpoint = EndpointChooser.preferIpv4().choose(endpoints);
if (ldapEndpoint == null) {
throw new OpsException("Cannot find suitable LDAP endpoint");
}
// TODO: Maybe we should just reference an LdapGroup
// TODO: It sucks that we're logging in here as the Manager account
// LdapGroup -> LdapDomain -> LdapService
String authLdapUrl = "ldap://" + ldapEndpoint.publicIp + ":389/" + allUsersDN.toLdifEncoded() + "?uid";
String authLDAPBindDN = managerDN.toLdifEncoded();
String authLDAPBindPassword = ldapDomain.adminPassword.plaintext();
String requireLdapGroup = gitUsersDN.toLdifEncoded();
model.put("AuthLDAPURL", authLdapUrl);
model.put("AuthLDAPBindDN", authLDAPBindDN);
model.put("AuthLDAPBindPassword", authLDAPBindPassword);
model.put("requireLdapGroup", requireLdapGroup);