|  | 
 
| 
; L, [9 T  G1 o* r$ u* D. P/ L
x
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!您需要 登录 才可以下载或查看,没有账号?注册 
  Teamcenter二次开发源码分享: 获取当前用户信息
 & p6 z7 l) R, F' f" R- E# [6 w7 s  j5 G
 [mw_shl_code=cpp,true]#include <iostream>
 # C9 F# w% k; B% s! y2 u#include <sa/group.h>. e/ G3 a' q: O- D2 g* P/ b
 #include <sa/user.h>2 e1 R9 G5 [2 h
 #include <TC/LoggedInUser.hxx>
 7 o7 @' F& J( z/ G0 B$ I+ K$ a  m9 \/ C! E' `
 using namespace Teamcenter;2 }$ i" _' N; i) Q3 d7 H: g
 using namespace Core;$ D8 Q, ]" i* l/ w- ?
 using namespace std;% R  [) }8 v" s+ B6 n) h
 
 % V! ~& l* L4 D5 ^; f1 _# r, }static void reportCurrentLoginInfomation()
 * s/ L# Y. q2 q& x( J+ {5 x{
 ' `8 y; u2 u- h/ L    int ifail = ITK_ok;
 ; M2 {" u; {5 V7 T    LoggedInUser* loggedInUser = LoggedInUser::getInstance();
 ' ?9 J* I1 b* T" W% L    ; }' \4 w7 a0 F( M8 c* L
 tag_t currentUserTag = loggedInUser->getCurrentUserTag();$ {. J5 ~* U7 s7 h7 `3 x  b
 cout << "    currentUserTag: " << currentUserTag << endl;, g" Y) t% H2 `0 P* N; n6 [
 
 2 ?) O$ ]1 s- q2 z7 M    char *personName = NULL;1 a7 V9 m2 L3 i- Y3 g, K" q9 h
 IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));4 J9 u+ K7 T$ O
 cout << "    personName: " << personName << endl;7 o+ \6 _4 P4 y1 k
 if(personName) MEM_free(personName);7 q* J0 R; F- ?% D# m0 d& t9 [7 z
 5 C+ J( G. ~, V6 w. H0 N, B
 const char* userID = loggedInUser->getCurrentUserID();
 + J2 f6 ^! |+ h$ A4 {7 N    cout << "    userID: " << userID << endl;
 0 `/ o/ ], R- O9 y2 A7 g$ d! v" _: Z
 tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();  h  M6 j% Q( H/ q
 
 3 p: m6 A& [2 N4 e+ P5 O    char *groupName = NULL;
 0 \! s  j- h! R    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));3 s: l& T) t* k
 cout << "    groupName: " << groupName << endl;
 6 b# q9 G. ?7 s+ p    if(groupName) MEM_free(groupName);" W" L) e2 {$ X
 / L" L5 @0 F) G
 tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
 : u/ b- i, N, c; R& d/ n+ d    char *roleName = NULL;
 ; r5 a$ V" D* h1 Q: n    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
 ' m* r" Q6 D) w+ P, j    cout << "    roleName: " << roleName << endl;
 , G& l! ^- l$ Q$ \5 q4 J* ^    if(roleName) MEM_free(roleName);
 - v- L7 [( f) k& s7 P    ) s8 x9 G( j$ p4 H
 logical isDba = loggedInUser->isUserSystemAdministrator();
 ! z4 k9 D7 @( f9 w, s' I    if(isDba == TRUE) cout << "    User is dba member "<< endl;5 h% h. E, V/ d2 \& a8 H& @1 n, X
 if(isDba == FALSE) cout << "    User is not dba member "<< endl;
 # u" m: R' Y& H' X! t0 Q}[/mw_shl_code]" K, S1 J* T# M/ s$ \1 v. \- ?/ `
 
 | 
 |