|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 L" h; K6 X i- o1 O7 ]& `
Teamcenter二次开发源码分享: 获取当前用户信息
9 D2 j8 [2 r5 L+ P& t( O1 s Y i! z# ^3 C& g _
[mw_shl_code=cpp,true]#include <iostream>
, ?+ L1 s8 x9 `0 ?3 O3 r( T3 R#include <sa/group.h>
& N: ?' {; u' E0 a#include <sa/user.h>2 C3 ?, u( {, p6 K0 A* v8 F
#include <TC/LoggedInUser.hxx>% m1 C$ h5 R1 N" V7 }! n
% E; h% J* T8 b0 dusing namespace Teamcenter;# B: J6 u6 d& G; F `# L, E2 Q1 d
using namespace Core;% J! T7 x7 A& W( q' ^5 [
using namespace std;/ }5 q0 a: y( ?3 M% |8 w9 `
6 _( U4 @. ?, v' d
static void reportCurrentLoginInfomation()
1 u ?) z" n6 `+ ~{
6 g5 J, ~" X- u' D+ J1 k8 V int ifail = ITK_ok;# Q7 k' v% w) H- f4 n% X5 v1 a
LoggedInUser* loggedInUser = LoggedInUser::getInstance();! @, x [2 S, q9 e
7 |! P I P9 ^6 N
tag_t currentUserTag = loggedInUser->getCurrentUserTag();6 D2 J6 O" p6 R! f; s9 I
cout << " currentUserTag: " << currentUserTag << endl;$ e; E, ?8 X+ v+ B/ \% u m
9 k4 @2 G, d# h8 s2 r) v; k" u
char *personName = NULL;
+ u5 Y9 U+ j0 ]- I7 ? IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));' H% b7 W) K* X2 Q: r# D
cout << " personName: " << personName << endl;
6 x7 Z9 a6 Z' c1 L if(personName) MEM_free(personName);. o9 p0 n8 l+ I+ N: m/ Q7 F
4 Q: D% A$ |- n" ?7 n% a' Q, n const char* userID = loggedInUser->getCurrentUserID();: f7 j+ D8 J6 m% Q: Z( z1 j
cout << " userID: " << userID << endl;' G- R. m7 a) d5 Q6 ~7 g
! C2 ^7 {; p4 h tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();3 m5 H0 }7 N5 t. c; _: U. ?
- x+ X0 P7 n3 z d8 J) Z char *groupName = NULL;
7 i4 S% [4 { E IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
6 d" |) }1 c3 C. f: Z* S6 @% u cout << " groupName: " << groupName << endl;
5 C+ c5 M5 P- A9 z. u if(groupName) MEM_free(groupName);7 Y% F% w- F% A
4 S K7 u& z* U& I9 s
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
8 q; L9 o& U( s char *roleName = NULL;3 C5 J9 m B) R. u! l7 i' \
IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));6 A# V9 E9 W0 Z! K2 N9 X. t# Q
cout << " roleName: " << roleName << endl;; T* [8 ?* N, G9 }& s- o- e
if(roleName) MEM_free(roleName);
3 h' y1 X, T) _& ^ ! G8 {) |' M/ s4 {1 U1 {+ w, H0 S
logical isDba = loggedInUser->isUserSystemAdministrator();
" H7 a" F- k0 s+ _ if(isDba == TRUE) cout << " User is dba member "<< endl;$ t+ q1 P4 \$ f Q* q) c2 A
if(isDba == FALSE) cout << " User is not dba member "<< endl; * ~8 I7 t( m+ |! k9 L
}[/mw_shl_code]0 X' U$ c5 y9 c, q
|
|