|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
7 D7 F. s- b+ K$ \
Teamcenter二次开发源码分享: 获取当前用户信息
1 }! m; k) z) s& D+ t
5 V& t9 _/ `4 t! L[mw_shl_code=cpp,true]#include <iostream>
3 G3 |( ?, d9 e" S#include <sa/group.h>
6 L9 Z$ o3 y6 j) P#include <sa/user.h>% E/ x, F; a8 u! s
#include <TC/LoggedInUser.hxx>2 x3 _! b8 g6 S7 y
, \1 J* V9 e/ P8 U4 q. Ousing namespace Teamcenter;9 ^/ F3 @6 [, {- x, D c
using namespace Core;
% t! X0 Y2 |0 V2 H5 k C! C2 _using namespace std; E& z; J5 R4 l: `
: H+ m7 j( B3 v. z( K: pstatic void reportCurrentLoginInfomation()$ Q& u' {6 H2 y1 D
{+ l D; ]5 p& t/ g
int ifail = ITK_ok;
. o, t: V7 K& i% \6 B LoggedInUser* loggedInUser = LoggedInUser::getInstance();
1 E5 i+ J* x- }) `* U( ^. ?& G, } * [" h7 F1 _3 b( \( M$ c9 z! p
tag_t currentUserTag = loggedInUser->getCurrentUserTag();
( y- F8 k J1 C8 t* w- J cout << " currentUserTag: " << currentUserTag << endl;. j( x" r+ t/ j0 H7 [+ u- ^
! ]9 C }& K; c! D8 ]$ c char *personName = NULL;
" }3 r3 I4 W: s, P" `# W IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
' `2 {+ @: U. I1 }8 F& V' D3 l% M" l cout << " personName: " << personName << endl;
+ @. L5 g! C) K$ f6 d if(personName) MEM_free(personName);% b1 Y# l/ \3 ^: Q# Q8 f# v, J
* z( u: y. {( U const char* userID = loggedInUser->getCurrentUserID();
# @' M) i6 W L3 v3 Q5 P0 s cout << " userID: " << userID << endl;6 N3 h g" |( E5 j4 g
0 J. e/ W" J% g+ l
tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
e6 B8 X" I+ ~, c/ m
; O5 C4 b' A* w0 @) f char *groupName = NULL;
. v/ G- W+ m e% g. N IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
) w( E3 Y7 v1 H8 P- Y+ K' `; `, R cout << " groupName: " << groupName << endl;
( r: G: Y2 E* i if(groupName) MEM_free(groupName);& m7 M! l+ N3 S" ]
, h' T @* { J7 b* E3 R R. b0 F
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
+ S) s9 U" B* b3 j char *roleName = NULL;
; x$ R8 {' x! E! U6 G IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
/ c4 t4 S, ^9 o& r! l8 ~) \& j" ~ cout << " roleName: " << roleName << endl;
, m1 v, B; \3 D if(roleName) MEM_free(roleName);
- j( c/ ^8 f! m# P2 l
4 h& m3 e% n8 Q+ \7 d logical isDba = loggedInUser->isUserSystemAdministrator();/ p+ T: V/ d( Y6 L0 @
if(isDba == TRUE) cout << " User is dba member "<< endl;
/ K: ], u6 s9 G; F- {% K0 p if(isDba == FALSE) cout << " User is not dba member "<< endl; 1 `$ L- [9 {9 J9 W1 ~
}[/mw_shl_code]
/ {. T& o9 a# Z; V/ q& t" v4 J z |
|