/** * check is remote host is windows * * @return true if host windows * @throws JSchException * @throws IOException */ boolean isRemoteHostWindows() throws JSchException, IOException { if ( this.windows == null ) { StringBuilder output = new StringBuilder(); int code = this.executeCommand( VER, output ); this.windows = code == 0 && output.toString().toUpperCase().contains( WINDOWS ); } return this.windows; }
/** * Get current user on remote host * * @return name of user on remote host * @throws JSchException * @throws IOException */ String getUser() throws JSchException, IOException { StringBuilder output = new StringBuilder(); int code = this.executeCommand( WHO_AMI, output ); if ( code != 0 ) { throw new JSchException( "Could not get user name on remote host (error code: " + code + ")" ); } return output.toString().trim().toUpperCase(); }
int code = this.executeCommand( ICACLS + windowsAbsPath, output ); if ( code != 0 ) { return result;
/** * get user group on remote windows host * @return list of groups + user person * @throws JSchException * @throws IOException */ List<String> getUserGroups() throws JSchException, IOException { if ( userGroups == null ) { StringBuilder output = new StringBuilder(); int code = this.executeCommand( WHO_AMI_GROUPS_FO_LIST, output ); if ( code != 0 ) { throw new JSchException( "Could not get the groups of the current user (error code: " + code + ")" ); } this.userGroups = getUserGroups( output.toString() ); userGroups.add( getUser() ); } return this.userGroups; }