|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 G( {* J, ]; w& I `# G
Teamcenter二次开发源码分享: 获取当前用户信息
2 _- L7 o: d) E7 g3 ?1 i7 }# j+ s4 h* K1 A# N* W: E
[mw_shl_code=cpp,true]#include <iostream>* p2 F7 u2 g6 k9 o
#include <sa/group.h>, C& l" s/ p3 m% r+ c# u
#include <sa/user.h>
k1 k+ i* W2 o#include <TC/LoggedInUser.hxx>
9 f- Q3 }. e, L; t# O" T9 _8 G5 A3 F1 S
1 a+ U: P1 M' D( g) x1 musing namespace Teamcenter;
4 E5 | V& l4 U5 t0 R& j; h; Q/ busing namespace Core;/ o p/ t1 f0 B7 w* w, G
using namespace std;
% a6 A! D. A5 v$ d* p# ^+ q. v! F5 a. n$ L7 |
static void reportCurrentLoginInfomation() U$ p# p( F& J \4 J- M1 w1 R
{) J$ G7 C. C. O1 w v
int ifail = ITK_ok;4 t8 R G" b9 T' t9 [
LoggedInUser* loggedInUser = LoggedInUser::getInstance();. U: p( d l. Y: ]
7 O: E, G% d U0 c) B3 U
tag_t currentUserTag = loggedInUser->getCurrentUserTag();% Q7 g: c% `9 `* _% T3 A8 K" ?
cout << " currentUserTag: " << currentUserTag << endl;5 { y' l/ i$ G$ u! t
4 O5 _, _7 f6 d+ v9 e
char *personName = NULL;
. P1 }3 @9 c& J) d" M) X/ U& i! Y) m IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
) b" h8 q" G4 w/ q1 R1 c cout << " personName: " << personName << endl;6 A8 f. S, e8 x" N. d7 D
if(personName) MEM_free(personName);3 M- e' y$ f- o% A' e
c( }! X- h: p$ Q
const char* userID = loggedInUser->getCurrentUserID();
. s, d% M( e, [3 G$ P cout << " userID: " << userID << endl;5 W5 x( T+ i. {4 r
+ `/ K; F' p1 K+ r tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();' l9 A+ q$ r0 s+ w5 j g- k1 F
" U, n" w: Q; } char *groupName = NULL;
* t4 U$ x- l' H$ ^8 l0 C2 i IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));+ w8 B6 @2 Y( ~6 f
cout << " groupName: " << groupName << endl;, `) `. ]( Z# b$ r
if(groupName) MEM_free(groupName);" y" I9 N! a2 I5 O& G& B
; `0 K. @( R; f7 E6 E/ s( j tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
/ _5 ]8 _0 x+ U! C1 g0 R8 B1 e char *roleName = NULL;% f `4 W: ^# h9 ~8 ~
IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));+ H6 l- f1 J c! K
cout << " roleName: " << roleName << endl;
4 M9 G: ]6 O M: }) }: L; D$ M6 A if(roleName) MEM_free(roleName);
5 a% x" s0 z4 p. {, F# I, E
) }, Z& o" J, v, ] logical isDba = loggedInUser->isUserSystemAdministrator();
. l: D2 O- [7 e6 e E" b if(isDba == TRUE) cout << " User is dba member "<< endl;
9 {8 k5 g6 A' x if(isDba == FALSE) cout << " User is not dba member "<< endl; 8 B: j5 s- G* S3 `% }( F
}[/mw_shl_code]+ ]' ~. ` t& A& l
|
|