|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% E4 S2 k: F0 z7 ]5 }
Teamcenter二次开发源码分享: 获取当前用户信息
- A. }" t+ n& M5 z. Q$ N8 n# ]/ l# S- }/ _1 j8 B# m
[mw_shl_code=cpp,true]#include <iostream>7 }6 O! i$ f' w9 a. n2 H
#include <sa/group.h>* P1 u1 B+ S7 p' q( N, w
#include <sa/user.h>
# s! q# \( [* l! m#include <TC/LoggedInUser.hxx>
" o4 [$ A" J+ F2 s+ t/ \) ?3 G+ h. v7 Q: D4 ]0 x2 M
using namespace Teamcenter;/ w i2 c6 b, b+ V/ A6 ~1 k& u
using namespace Core;6 [+ P3 l8 w7 h- k: q2 w
using namespace std;/ |, T3 N9 |) s6 b0 \0 `7 V
' ]' B0 a ]) x! b/ kstatic void reportCurrentLoginInfomation()" B) t i+ A& e' g5 d
{# m& t# R# g4 u+ z |8 [
int ifail = ITK_ok;
/ f4 d+ s3 ]8 Z# M' P, o LoggedInUser* loggedInUser = LoggedInUser::getInstance();
) b X, q- Z( Z1 Q1 S" C8 P
7 M w; O: |% D7 b0 g+ c tag_t currentUserTag = loggedInUser->getCurrentUserTag();
9 r, t) B8 y' j. m4 @ cout << " currentUserTag: " << currentUserTag << endl;, B: Y2 i5 h9 s. e
7 L0 k5 h( [1 M6 T
char *personName = NULL;2 ~- g5 e- E/ Z7 L
IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));/ G6 P3 _& e1 n* _
cout << " personName: " << personName << endl;/ U, N% |; e& x$ G6 f
if(personName) MEM_free(personName);# @& W) }' V G" G1 `. B% c
$ ]! T9 e w% y2 v5 P/ r/ G const char* userID = loggedInUser->getCurrentUserID();
5 X: V& ^! x8 Y7 B m cout << " userID: " << userID << endl;& n; P) W' t/ A* ]2 Q" H
* W* c4 _- O% n/ f' U tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();/ t, U# o# U0 p# p( @
3 H( b# ]! a E7 w& o* q
char *groupName = NULL;! d) w! H1 b1 d8 H+ X% w
IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));$ [- v# S$ H9 n% I
cout << " groupName: " << groupName << endl;
: u" X, [7 u% O6 C' N$ d if(groupName) MEM_free(groupName);2 v6 u$ x$ s6 n4 w1 m
6 O* Z$ p. ]( I }: Q6 r4 o: s. w tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
) O. o# w3 S g+ t: n! \0 c char *roleName = NULL;
9 [5 l/ d3 r$ g. o IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));# s1 u- y W u, l0 r. O2 \* n! f
cout << " roleName: " << roleName << endl;
6 E" O/ W: u0 z; p( \3 u6 A if(roleName) MEM_free(roleName);
. a; t/ z$ m0 D1 m
7 Z. t8 F' F" t# E& p logical isDba = loggedInUser->isUserSystemAdministrator();* i, S1 X: L1 C
if(isDba == TRUE) cout << " User is dba member "<< endl; T' ~4 c9 s `4 N* {: F
if(isDba == FALSE) cout << " User is not dba member "<< endl; * \. n4 i8 p( a5 a( B
}[/mw_shl_code]
# E3 z/ @7 E# c# |% m9 B |
|