查看: 2738|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

积分
82265
QQ
发表于 2020-2-8 09:34:22 | 显示全部楼层 |阅读模式

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

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

×
2 _9 f* E4 _" G9 g4 A
Teamcenter二次开发源码分享: 获取当前用户信息
+ w% U2 J& ]0 k# J8 l$ Z  l6 m' l
+ |5 C! L: x  r( X' `- L: H[mw_shl_code=cpp,true]#include <iostream>) f& {/ w0 v8 g$ j+ {+ v- }- s4 J
#include <sa/group.h>' r/ T9 w! e% o2 ^. o
#include <sa/user.h>
2 O# E& R) z0 i9 o* w, U#include <TC/LoggedInUser.hxx>
$ _6 p) c7 y6 {. p/ F/ B* B
' C; c3 i2 k" T- ^using namespace Teamcenter;
, Y8 ]7 F. z0 W/ u: v' `" f5 cusing namespace Core;" t# \' m% a' O
using namespace std;. s  c% j& j2 F! w

/ F" s6 I3 [, O" j3 m9 `- Xstatic void reportCurrentLoginInfomation()
" b4 t7 l# {- H( A( l3 _* n{
& C) K: V0 C7 C    int ifail = ITK_ok;
5 O( @3 k) U+ W/ b' u    LoggedInUser* loggedInUser = LoggedInUser::getInstance();$ S4 b* c7 s5 E  {% [' c# n% n
    ' A) Q9 P' o8 p" p
    tag_t currentUserTag = loggedInUser->getCurrentUserTag();' m2 X7 ~) v, F8 Y! M
    cout << "    currentUserTag: " << currentUserTag << endl;
1 b* {) W* L$ x- k5 d    . D$ L% Y3 ?" C* W) B: a
    char *personName = NULL;
* K/ k. [3 n5 Y    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
3 Q$ a5 {. P& L" o2 E    cout << "    personName: " << personName << endl;& u6 Q# h# p  p+ f1 W! u5 k" l# S2 {
    if(personName) MEM_free(personName);2 U4 F$ v& K$ x9 T* l$ S6 X4 Z
   
6 z: W- o9 e' R    const char* userID = loggedInUser->getCurrentUserID();
& p$ e8 y5 z& w& R5 C) u: ^    cout << "    userID: " << userID << endl;
( g7 l& b# e) f* ^
! `5 }7 s( `3 K( B    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();6 ~5 P; [9 X4 V3 f
    % S4 Y& t( p# t, L' _% C
    char *groupName = NULL;1 n# k* @# |* c: V
    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));% \& A. B( \! {) K: u
    cout << "    groupName: " << groupName << endl;8 m: D8 m4 E% c" C
    if(groupName) MEM_free(groupName);/ o4 g1 }$ r8 n* y
& J, ]; e6 k1 c( \/ m# g/ R
    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();% F* J$ j/ i* ^) G
    char *roleName = NULL;! J7 U1 J/ [) C( Z- `, z, l
    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
& M2 w  T9 l. k# w/ F% o    cout << "    roleName: " << roleName << endl;4 l# z3 j$ y0 ~' n; k2 Q" f
    if(roleName) MEM_free(roleName);
( S6 G& L6 Y$ y# R   
, b, e0 ^5 _" H3 N; N5 K, W    logical isDba = loggedInUser->isUserSystemAdministrator();
& q9 d! C( ]6 g3 R0 M( K" H    if(isDba == TRUE) cout << "    User is dba member "<< endl;; ], w3 `- R- K1 C$ E
    if(isDba == FALSE) cout << "    User is not dba member "<< endl;       6 W8 H* @" g( V6 G  c8 v2 A& b
}[/mw_shl_code]
; M* D; [* h; B" V1 s
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部