PLM之家PLMHome-国产软件践行者

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

[复制链接]

2020-2-8 09:34:22 2204 0

admin 发表于 2020-2-8 09:34:22 |阅读模式

admin 楼主

2020-2-8 09:34:22

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

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

x
) [. w& m" ]& B
Teamcenter二次开发源码分享: 获取当前用户信息
" D% \4 t% O3 f- H  W( ?- G6 x( s9 D. P. T, L
[mw_shl_code=cpp,true]#include <iostream>
! x" K( S7 e. x/ d#include <sa/group.h>4 F2 e) @3 j  h2 R. v+ H% H7 p
#include <sa/user.h>8 e3 h0 ~; W8 D6 z
#include <TC/LoggedInUser.hxx>
' \& ^9 ?# G( d$ q4 Z3 t8 d& ~$ ]; C! a9 L
using namespace Teamcenter;: r, @% V3 {2 k2 ^' x: C
using namespace Core;% i# u0 o; s( ~* K% J2 ?3 H. U
using namespace std;3 ]( g/ ]( ]6 R4 ]6 U$ G

# {- p5 U$ F/ z: ustatic void reportCurrentLoginInfomation()0 i& w0 Q/ `/ q9 x+ H
{" t3 p. ^. _9 p; f) j3 X/ s; J, g
    int ifail = ITK_ok;9 @2 G# B0 i: G. D
    LoggedInUser* loggedInUser = LoggedInUser::getInstance();& g7 l' h8 v' i
    8 ]9 D+ R1 Z7 P8 Y+ m  |
    tag_t currentUserTag = loggedInUser->getCurrentUserTag();
% q) F# _' o6 I    cout << "    currentUserTag: " << currentUserTag << endl;
; Z# q, d; J2 c    ' b1 j+ c, ^$ s! g4 q& x
    char *personName = NULL;
2 ?7 _6 p- ^0 Z# Z9 L% O" [! t" F    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));3 c4 D/ I# Z( Y
    cout << "    personName: " << personName << endl;  ?5 d/ p, j, I/ E$ }  v
    if(personName) MEM_free(personName);
/ B2 `# B: _$ [    , m! ]0 @8 U2 q6 [7 Z1 D
    const char* userID = loggedInUser->getCurrentUserID();2 p" N) ~) F; I; p1 `  T- q
    cout << "    userID: " << userID << endl;8 i/ V' i% a5 z3 L9 @  r! E# Y4 I; `
# i# `6 k( j: a5 j
    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
* y' e- r$ E8 Y; P% @1 n1 w9 R, }    / h& ^+ ?0 y$ F% N5 D. h3 @2 w
    char *groupName = NULL;
4 B$ J( |" w7 u% S- D    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
) U8 S. Z9 l, f" @( W    cout << "    groupName: " << groupName << endl;
0 N. |( d' |4 c, j( b    if(groupName) MEM_free(groupName);
* `: t" r3 G& K# w- y4 Z& n3 }4 q* C+ o, o
    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
) q3 Q# i( l! L$ {7 s! L* K( q    char *roleName = NULL;
9 i7 a/ |5 ]! c- a* l- o9 z+ v    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));( J& U  l' ^4 L) B
    cout << "    roleName: " << roleName << endl;, y+ e! y1 C. |0 }4 j
    if(roleName) MEM_free(roleName);# m1 i3 F$ D4 X! }. A* t% M
    , R' U5 M" o$ S$ L/ ]; S
    logical isDba = loggedInUser->isUserSystemAdministrator();
5 ]& M, y0 _5 H    if(isDba == TRUE) cout << "    User is dba member "<< endl;6 }8 i/ N$ ^; X3 G% m
    if(isDba == FALSE) cout << "    User is not dba member "<< endl;       & I" K) I) V$ z, b
}[/mw_shl_code]2 v' l, l/ S. p# H5 X0 |
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了