Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8944

Re: Get List of Users and their full name in tabular format using SDK

$
0
0

I have a "UserInfo" class that I wrote that gets this information.  I store the UserInfo objects in a HashMap indexed by SI_ID, then cycle through them to output the info into a csv file.  Here's the code I use to pull the information you're looking for (assuming that I have the IInfoObject that represents the user.)

 

    private Integer id;
    private Integer parentId;
    private String title;
    private String kind;
    private String cuid;
    private String userName = "";
    private String namedUser = "";
    private String description = "";
    private String email = "";
    private String enterprise = "";
    private String winAd = "";
    private String ldap = "";
    private String other = "";
    private Date lastLogon;

    public UserInfo(IInfoObject o, Date defaultDate, Logger log) throws SDKException{
        id = o.getID();
        parentId = o.getParentID();
        title = o.getTitle();
        kind = o.getKind();
        cuid = o.getCUID();
        parentCuid = o.getParentCUID();

        IUser usr = (IUser) o;
        userName = usr.getFullName();
        namedUser = (usr.getConnection() == CeUserLicenseType.Named ? "Named":"Concurrent");
        description = usr.getDescription();
        email = usr.getEmailAddress();
       
        //get the last logon
        try {
            String s = PropertyHelper.getStringProp(usr.properties(), "SI_LASTLOGONTIME", log);
            if (s.isEmpty()){
                lastLogon = defaultDate;
            } else {
                lastLogon = DateHelper.stringToDate(s, defaultDate);
            }
        } catch (Exception e) {
            lastLogon = defaultDate;
        }
       
        //check the aliases to determine what kind of user this is
        IUserAliases aliases = usr.getAliases();
        for (IUserAlias alias : aliases){
            if (alias.getType() == IUserAlias.ENTERPRISE){
                enterprise = "X";
            } else {
                if (alias.getAuthentication().toUpperCase().contains("LDAP")){
                    ldap = "X";
                } else if (alias.getAuthentication().toUpperCase().contains("WIN")){
                    winAd = "X";
                } else {
                    other += alias.getAuthentication() + ",";
                }
            }
        }
    }

 

-Dell


Viewing all articles
Browse latest Browse all 8944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>