|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ o. q9 S% |% G4 t/ l, q* u
Teamcenter二次开发源码分享: 获取当前用户信息
6 v+ n) ]# u, v4 U- o& X8 Q! ^5 ~% C! P' o P% O$ T1 C$ O* W" y
[mw_shl_code=cpp,true]#include <iostream>
5 u* C6 M0 U/ V b- l4 A#include <sa/group.h>
9 Z, c( ^0 d* V: S) N5 e#include <sa/user.h>
" ^. i" R& G) r3 h; o#include <TC/LoggedInUser.hxx>
0 p& A8 }) R/ [1 x. a' r6 T* |6 I
; @9 l3 S7 @5 L0 Qusing namespace Teamcenter;4 Y# ]% d: p8 ^1 A1 p2 r5 |
using namespace Core;0 p C) \6 x3 t3 K
using namespace std;
, r! T3 @* ]1 |2 h/ O+ _
3 X4 q) C. y5 M0 sstatic void reportCurrentLoginInfomation()+ u# p& e- d/ W) W5 H
{
" Q$ M' L* q _1 l int ifail = ITK_ok;
3 f& z4 ], t1 U0 U- r2 p LoggedInUser* loggedInUser = LoggedInUser::getInstance();8 ]0 [+ L" W! s" C0 A
2 F6 _: u' |1 c7 E8 ]* I" B tag_t currentUserTag = loggedInUser->getCurrentUserTag();
' g, B2 A: W! d: g( X8 R cout << " currentUserTag: " << currentUserTag << endl;: q+ Z! Y" ~% v" _
6 E4 p+ r$ d- o( Z" K y, ^
char *personName = NULL;
* z8 R7 S# a1 _* N. U5 T IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
1 w9 M( k2 T0 {5 B; I7 ~ cout << " personName: " << personName << endl;! D( m1 R3 N* i ^) F) \
if(personName) MEM_free(personName);- p! v9 K+ [4 W' s; C m y9 N0 L
8 O9 r8 F2 [' z5 e/ r2 Y7 ? const char* userID = loggedInUser->getCurrentUserID();6 d' |6 x3 j0 z% U4 e" i; |
cout << " userID: " << userID << endl;. e9 T; y; x3 A( j& `! x
8 A, ?% D/ q5 H( x* K8 B; ^ tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();" {) _7 q S# Z* E0 c1 P; l; }4 N
! l2 H5 _& q, F8 e$ n/ U char *groupName = NULL;
3 E: F; M6 W8 `7 m6 |! ] IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
) b% O$ f& j+ e* v cout << " groupName: " << groupName << endl;
) s" q! G( ]! V7 e- t% n5 H if(groupName) MEM_free(groupName);* w$ i" O' f% e( }* s! W
3 I4 H0 [+ M) f% V/ a5 j" Q1 t+ Y
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();+ }" P" {/ X2 G0 o
char *roleName = NULL;( Y; v' \7 j7 T& T6 K
IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
' T& X& J$ \( f* n0 L cout << " roleName: " << roleName << endl;9 `5 {. g; e6 v2 ?3 R8 J0 U" N
if(roleName) MEM_free(roleName);
4 h3 b% r% |& s+ g! }5 z3 l {1 I, j
) b2 J5 E: j, g logical isDba = loggedInUser->isUserSystemAdministrator();
) B* z7 [$ l2 k- [ if(isDba == TRUE) cout << " User is dba member "<< endl;8 V1 G/ k- ]+ a
if(isDba == FALSE) cout << " User is not dba member "<< endl;
5 [4 P. r0 b1 V# ~8 L; s}[/mw_shl_code]
) A* `0 [: ?2 Q |
|