PLM之家PLMHome-工业软件践行者

Teamcenter二次开发源码分享: 获取当前用户信息

[复制链接]

2020-2-8 09:34:22 2288 0

admin 发表于 2020-2-8 09:34:22 |阅读模式

admin 楼主

2020-2-8 09:34:22

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
4 c% c' x' R6 b* y. H% y& d! v
Teamcenter二次开发源码分享: 获取当前用户信息0 r- Q" K# b7 [! R
! [8 {9 x- `* [7 E9 E& H
[mw_shl_code=cpp,true]#include <iostream>
/ ~9 R: J( `* n5 O( I#include <sa/group.h>
$ {8 h2 N3 g1 H; K4 F! M#include <sa/user.h>/ m+ J  d/ Q- D# A8 M7 Q! r
#include <TC/LoggedInUser.hxx>
1 ^; Z5 O' m4 i& x2 `
  U# g8 U! f4 K. n+ Iusing namespace Teamcenter;
# m6 W1 x* L2 O0 b$ S; Rusing namespace Core;
& d5 i! H+ E, ]5 ~) C$ }# dusing namespace std;0 W" l, \0 R: N5 m" i% J: f5 b
) x8 S" Q. \" R% W
static void reportCurrentLoginInfomation()7 Y8 P. [& c) @7 X8 E' _' g
{
; z0 c& m# B  ~9 e1 l# B8 f# w, W2 Y    int ifail = ITK_ok;
3 f/ A/ a8 e1 E; t/ ], H) T* D    LoggedInUser* loggedInUser = LoggedInUser::getInstance();# v7 [8 n' P% A9 k7 h4 W
    $ C3 d7 x1 m# X/ }7 F7 G& U
    tag_t currentUserTag = loggedInUser->getCurrentUserTag();1 ^& z* W# k! X0 B9 I$ Q! i
    cout << "    currentUserTag: " << currentUserTag << endl;
! X  R. [9 u; l  J/ S% {   
; R& d' R, O5 }% v& S$ J    char *personName = NULL;
1 f, ~. d0 P: J4 v: `$ R* Y2 w    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));2 j+ d' ~0 F! c" c1 L! S
    cout << "    personName: " << personName << endl;) w3 Y: L" u: A4 V
    if(personName) MEM_free(personName);
) u% x1 y+ q+ E. J3 F2 v2 C    * Q2 J( r' f" `0 E% r9 Y
    const char* userID = loggedInUser->getCurrentUserID();
; @  A9 d) f1 Z' k2 B7 Y    cout << "    userID: " << userID << endl;
, [3 Y' K: U: i8 D8 U' ]3 m0 G) s0 p9 L8 Q( ?' ?& d
    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();' I$ K) ^8 a$ a' _: Y' D
    0 u6 e& d& g# `( W: [4 [7 G6 c
    char *groupName = NULL;
) M7 d+ c0 t/ f) e! D# Q9 {    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
5 A) d. M) A5 _4 G# {    cout << "    groupName: " << groupName << endl;" {2 E2 i+ c! @2 w3 I8 `1 M2 L+ U
    if(groupName) MEM_free(groupName);
& I2 G' C( f; m; N& F5 D1 q
' A' f' b3 w0 F6 f, O% e4 p, i3 @8 j( l    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();* b0 [% h8 j- l1 L& q, l
    char *roleName = NULL;- ?! ^" B+ O& C5 e% }
    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
# o- Q& ]2 F7 m* O& U( j* j% Y0 \    cout << "    roleName: " << roleName << endl;
3 t: J8 I. s( G/ {9 ?! C& ]    if(roleName) MEM_free(roleName);' P$ D- f4 Y! j
   
$ a+ }# \; c" `    logical isDba = loggedInUser->isUserSystemAdministrator();
6 c8 m6 N) @# D0 C3 @/ n    if(isDba == TRUE) cout << "    User is dba member "<< endl;
  g4 D; i) u. d$ c- f    if(isDba == FALSE) cout << "    User is not dba member "<< endl;      
" A) k) ]$ `/ r: g9 c( X3 H8 _}[/mw_shl_code]
. c" G: [; C' T) s$ \6 K
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了