查看: 2485|回复: 0

Teamcenter二次开发源码分享: 获取当前用户信息

[复制链接]

4

主题

3

回帖

40

积分

管理员

积分
40
发表于 2020-2-8 09:34:22 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×
* U+ q: l# P& I/ S
Teamcenter二次开发源码分享: 获取当前用户信息
5 A! J* K1 G2 o9 p: o
6 p% x3 s# K$ a1 a0 S[mw_shl_code=cpp,true]#include <iostream>
" u* K8 V# e) S9 G( _; s#include <sa/group.h>) L* v; d" B0 q  F9 n8 m$ R6 v3 @
#include <sa/user.h>
% o& B3 Q8 F& c# K# `& l% E& V1 ]#include <TC/LoggedInUser.hxx>! W. d& p) H8 Z$ }, j# \
! ]7 t1 i! y7 v- N) p! R& s
using namespace Teamcenter;7 J" h1 q) J6 O3 A( E% N
using namespace Core;
0 _/ ^" V( [/ R. Pusing namespace std;
# ~9 a# V: @' v5 K# \7 T2 u: ~9 g4 F& m4 d3 {
static void reportCurrentLoginInfomation()1 P% O3 \, o3 G# h; Q( d4 K7 L
{3 w) C/ C; Z8 U, V& v
    int ifail = ITK_ok;
( P) n& B7 V& U0 I5 U( X    LoggedInUser* loggedInUser = LoggedInUser::getInstance();. v; N$ \; ?  U) O' V* A
    , u7 c( E0 f' _, D" c2 e9 U
    tag_t currentUserTag = loggedInUser->getCurrentUserTag();
! X- m. t5 S: A2 J( |% j    cout << "    currentUserTag: " << currentUserTag << endl;) H0 N2 X. t# b6 I1 n- c! h8 o
    # u* e) E; Z" d  p; x  H" [
    char *personName = NULL;
# o9 @* P3 U7 ?    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
- V; Z7 o+ ?6 N# `9 J. D6 f5 c( k    cout << "    personName: " << personName << endl;
- R6 P, ?9 k3 f- B) G9 J0 M- Q5 m    if(personName) MEM_free(personName);3 u9 Z( {; }$ t( Q
    3 w% H; r- F' c  T* a
    const char* userID = loggedInUser->getCurrentUserID();
* l! v; n$ ^% ?6 [) p7 e! b    cout << "    userID: " << userID << endl;- j- l1 f' R2 a% ^) j

# m% C' E) _, V! V    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
! W8 L# T5 O" H6 Z( z3 l. Q   
# \( e0 v, O6 S( O    char *groupName = NULL;
% ^# M% `  ~# t" U& @  Q    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
* p( m3 c" A) [  D+ ?" l    cout << "    groupName: " << groupName << endl;- J( W, T; X$ i0 j$ [
    if(groupName) MEM_free(groupName);7 T1 h  u# ~# `0 n8 q* l4 Q! ^. D  I
1 \  S/ O% ?$ s. I& P" v
    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
$ J* J" I- e1 Q    char *roleName = NULL;' G- l9 j, j) s* M- R  Z7 q
    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));1 `% Z! N2 D4 v7 x! t- w
    cout << "    roleName: " << roleName << endl;1 a  j4 o/ b9 W( A
    if(roleName) MEM_free(roleName);
4 H0 K' `. O3 e   
% v( J( y0 I% o5 ^9 w8 m9 s. r    logical isDba = loggedInUser->isUserSystemAdministrator();
1 e. Z& `, I' j- V* d    if(isDba == TRUE) cout << "    User is dba member "<< endl;  q7 M3 V# s6 Z9 o0 r
    if(isDba == FALSE) cout << "    User is not dba member "<< endl;      
! j; C2 @8 a8 v}[/mw_shl_code]
0 s6 ~5 P% D% P
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部