|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 W* n {# l e
Teamcenter二次开发源码分享: 获取当前用户信息
! W m+ u, q$ W* o5 T. [6 [2 R" M
5 X0 X' m6 f" n[mw_shl_code=cpp,true]#include <iostream>* C6 C: U! a1 `* z v: y! B/ D E3 k
#include <sa/group.h>
* `( n+ E" E* x' j3 S0 m6 L#include <sa/user.h>
* L7 X9 w9 Y( _7 X! Q3 f8 j: X$ G#include <TC/LoggedInUser.hxx>+ E5 N- T+ t9 R9 f
5 g) g2 O3 C h
using namespace Teamcenter;5 a0 _) b" R3 @8 [3 B: v( I
using namespace Core;( h' t% [ V$ J
using namespace std;( Y. x0 X' ^* f, G7 M
* g+ _! }. D% Z1 V! |$ wstatic void reportCurrentLoginInfomation()
8 P% z' Q$ b% D) M{
' f* ]5 u% v# c) c8 f, {2 Z' ^8 f int ifail = ITK_ok;0 M; v/ P% E/ ?) j b- B
LoggedInUser* loggedInUser = LoggedInUser::getInstance();
1 E5 |3 N v; b) F
8 o8 g! Y/ |0 a* O( ^ tag_t currentUserTag = loggedInUser->getCurrentUserTag();
; _% ]( e2 c4 f/ K cout << " currentUserTag: " << currentUserTag << endl;
7 D; f4 N" p2 n4 y q9 @ % c( U; U( y7 q- C9 c2 K
char *personName = NULL;
( M* K* y0 R/ `6 V IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
1 {7 R6 w- D" i( u6 m/ c8 ^/ @ cout << " personName: " << personName << endl;; k0 l0 m, k4 F+ {9 F7 p1 v
if(personName) MEM_free(personName);
, v0 H7 M) `; X& o. F+ t& r
: X6 z7 Y K, X4 ?4 ]3 k% `# z const char* userID = loggedInUser->getCurrentUserID();: e: d' o: w5 d& d5 h
cout << " userID: " << userID << endl;% r9 r4 F! ?) G3 N3 o; E9 i
. d/ b8 t, w6 V' W S( z tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
+ [) f1 F: e# E" `( l- b
8 Y, D3 Y0 i/ z1 G; Q char *groupName = NULL;
$ q5 D" M/ P& z3 M+ P8 G IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
: E/ C( e( b. ~. I8 Q6 H! O cout << " groupName: " << groupName << endl;
7 t9 p0 N! m3 S7 X5 e* D& E6 U3 ` if(groupName) MEM_free(groupName);/ Q0 S, b* u% |
* ~& ~* T+ A4 ^* l. f$ C
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();' @/ h; ]! A {0 G. |3 m3 m
char *roleName = NULL;
$ `$ p" X/ ?: q5 `! [! d/ U2 t IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));. c% M3 y+ Y0 e- L, |9 m
cout << " roleName: " << roleName << endl;' |9 \5 _: D- A8 S8 Q. @
if(roleName) MEM_free(roleName);8 h' P1 x4 N8 P0 i1 d; v, {* t
; W; ?/ _) \+ k
logical isDba = loggedInUser->isUserSystemAdministrator();
) b7 a8 d+ ]9 E0 N. D4 @1 a" p6 d if(isDba == TRUE) cout << " User is dba member "<< endl;
$ p0 a8 J; C- p! R6 o1 N3 E& Z' a if(isDba == FALSE) cout << " User is not dba member "<< endl; % ^+ C: k1 E. G* h9 F
}[/mw_shl_code]# F, I& b: R% o6 t
|
|