import com.eruces.teagent.TEAgentConnection;
import com.eruces.teagent.TEAgentException;
import com.eruces.teagent.TEAgentConnectionFactory;
import com.eruces.teadmin.Administration;
import com.eruces.teadmin.AdminException;
import com.eruces.teadmin.PrincipalInfo;
public class Java_Admin_Principal_GetList_4
{
private String m_strServerName;
private int m_nPort;
private String m_strUsername;
private String m_strPasswd;
private TEAgentConnection m_conn;
public void getPrincipalList_4() throws TEAgentException, AdminException, Exception
{
Administration admin = new Administration();
admin.attachConnection(m_conn);
String[] strClsName = new String[5];
strClsName[0] = "UserAndPasswordInfo";
strClsName[1] = "WindowsPrincipalInfo";
strClsName[2] = "LdapPrincipalInfo";
strClsName[3] = "TransportPrincipalInfo";
strClsName[4] = "GroupInfo";
PrincipalInfo principals[] = admin.getPrincipalList( strClsName );
if( principals == null )
throw new Exception("Getting principals failed !");
System.out.println("Principals got:");
for (int i=0; i<principals.length; i++)
{
System.out.println("");
System.out.println(" " + principals[i].toString());
}
admin.detachConnection();
}
public void connect(String strServerName, int nPort, String strUsername, String strPasswd) throws TEAgentException
{
m_strServerName = strServerName;
m_nPort = nPort;
m_strUsername = strUsername;
m_strPasswd = strPasswd;
m_conn = TEAgentConnectionFactory.getInstance(TEAgentConnectionFactory.SECURE_USER_PASSWORD);
m_conn.open(m_strServerName, m_nPort, m_strUsername, m_strPasswd);
System.out.println("Connected to " + m_strServerName + " at " + m_nPort + " as " + m_strUsername);
}
public void disconnect() throws TEAgentException
{
m_conn.close();
System.out.println("Disconnected from " + m_strServerName);
}
public static void main(String[] args)
{
try {
Java_Admin_Principal_GetList_4 test = new Java_Admin_Principal_GetList_4();
test.connect("sampleserver", 8888, "admin", "password1A");
test.getPrincipalList_4();
test.disconnect();
}
catch (TEAgentException te) {
System.out.println("TEAgentException encountered: ");
te.printStackTrace();
}
catch (AdminException te) {
System.out.println("AdminException encountered: ");
te.printStackTrace();
}
catch (Exception ex) {
System.out.println("Exception encountered: ");
ex.printStackTrace();
}
}
}