|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: \# Y5 ~; R4 R! {; q" YTeamcenter二次开发源码分享: 获取当前用户信息
+ z+ B, _& e9 j* N% { N$ U
6 G. _% I# f8 V8 ]! }7 L1 a[mw_shl_code=cpp,true]#include <iostream>- X& p) \ n' p' ]/ P
#include <sa/group.h>! k c$ m, Y$ ?) C1 c+ l5 X- |
#include <sa/user.h>
' O" W6 O! W8 n/ g x% ~% m#include <TC/LoggedInUser.hxx># a# u4 o: }; @
0 j: Z: Y7 h* Wusing namespace Teamcenter;
% a( j. H3 J& x/ q+ Rusing namespace Core;1 r1 d# q K5 k" h- o! N, x" i
using namespace std;% @ E/ V0 F- @1 x2 ~& p& O6 v, X
* w, E1 ~% p- _- j* }3 ^
static void reportCurrentLoginInfomation(); s$ o1 d6 a! s( m1 b' l
{
- ]9 r4 A$ [; P- [8 N; m7 ? int ifail = ITK_ok;
) i2 l8 u7 [# a. k' {% a, ^ LoggedInUser* loggedInUser = LoggedInUser::getInstance();
& T' p. M% t. K6 R / F: H; h# B6 b2 a& W4 Q" s
tag_t currentUserTag = loggedInUser->getCurrentUserTag();. u* n a/ O. S
cout << " currentUserTag: " << currentUserTag << endl;! v1 V7 G0 {2 {& n& W
( f1 Y2 _/ q: Q
char *personName = NULL;' q5 C7 @% T7 t
IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
5 [! u" } O! e/ o2 e, p5 \+ B; C. j cout << " personName: " << personName << endl;- G( u* I4 ~& }$ n" d4 r! S; V
if(personName) MEM_free(personName);+ B5 ?+ T- p0 h( ^3 @8 R2 u, d
}7 o& @& U- W$ w$ y5 [. R+ Y1 G
const char* userID = loggedInUser->getCurrentUserID();0 ^1 ^+ \9 j5 W G/ n
cout << " userID: " << userID << endl;
! e7 ` G% [& f9 _5 Q. K% A% p
# i8 l) s! o' J6 x tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
: I) H& M) a" _# c% q* r ) V$ q! l: n% c$ a. t% [' A0 c% Q0 e
char *groupName = NULL;6 D8 X/ x5 u( ]
IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName)); k3 K# T. ~% i$ u
cout << " groupName: " << groupName << endl; A8 T6 u) J7 ]8 l8 c+ {) J
if(groupName) MEM_free(groupName);
4 v! q6 p+ q. O- q! k8 {! N
& D. n" v; |5 k2 B9 P tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();3 T* d$ O# F3 _
char *roleName = NULL;8 t+ X+ i$ T: u. H; E
IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));6 [& k; f3 f+ Y7 P
cout << " roleName: " << roleName << endl;8 z) _, S: p9 d
if(roleName) MEM_free(roleName);
) e) O3 @8 J' v" V6 y/ h
" v$ {3 ], R4 J: _2 w logical isDba = loggedInUser->isUserSystemAdministrator();/ N) @1 j) l/ C& E8 a4 C+ L
if(isDba == TRUE) cout << " User is dba member "<< endl;
! A2 h# g* e, _0 Y if(isDba == FALSE) cout << " User is not dba member "<< endl; / J/ x8 e4 A) y2 s, y' Z
}[/mw_shl_code] t+ S3 I; `& t2 X$ Q/ K8 A
|
|