PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:34:22

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

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

x
( B9 a1 |$ o) f1 o; t
Teamcenter二次开发源码分享: 获取当前用户信息& d/ D9 `5 p' l- ?2 @3 r

, s7 k% K2 P# _8 e& d( C+ [& G[mw_shl_code=cpp,true]#include <iostream>
6 a8 U7 z- o0 P#include <sa/group.h>% y. m6 E) U  r& ]9 s/ F; P# Q
#include <sa/user.h>
7 M0 r& K7 q2 E0 |" b#include <TC/LoggedInUser.hxx>6 r( [) {& ]( ^' z& m1 u- \

% z* Q; \% d. E4 \using namespace Teamcenter;
/ M2 Y5 L( c/ e5 z/ q8 m0 A+ a/ rusing namespace Core;) t/ @, p) h7 Z- F2 H
using namespace std;
' d: i) f1 T) _. \1 ~0 \
6 q9 c" |3 K" S+ c. Ustatic void reportCurrentLoginInfomation()( K2 e4 ~+ i! a
{
- _  a2 p( @, x0 ]9 m% D: A    int ifail = ITK_ok;: P2 D$ u0 t+ C; u# |0 D
    LoggedInUser* loggedInUser = LoggedInUser::getInstance();4 Y' n& O2 z8 [* L/ `
   
1 C( H+ T% Y! F) D    tag_t currentUserTag = loggedInUser->getCurrentUserTag();$ W' X9 P4 Y; \" J9 \
    cout << "    currentUserTag: " << currentUserTag << endl;2 M' w( S' Z3 b; m6 s# l
   
1 f0 P9 v. \+ c  u  _    char *personName = NULL;( u& k  |- x3 h8 t4 B( @; h
    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));8 l( e6 y5 @  C5 a2 T4 ^
    cout << "    personName: " << personName << endl;: l, w1 F/ m1 c/ Z' D
    if(personName) MEM_free(personName);
% c* S! h% W7 P    , W" \; W: D4 T( b
    const char* userID = loggedInUser->getCurrentUserID();
0 v) Y5 K- v1 C' {# _    cout << "    userID: " << userID << endl;$ F& N+ q) X- T1 s1 t  G

  ^0 e8 Z. O! [    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();0 W: k" Q; N# P7 F# R3 ]! V
    # r8 |$ }' i$ l7 e0 P% E; i
    char *groupName = NULL;
7 S. o, @1 ]- u! u% X2 z+ F$ n    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));! b' _2 w! Z( Y$ I) V3 N9 I
    cout << "    groupName: " << groupName << endl;
- V) p, {5 w) t2 C$ V0 e    if(groupName) MEM_free(groupName);
0 k9 l( @( M4 d5 T5 }4 J! a. e% ?
    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
, {# }  p5 p6 T! p; M, G    char *roleName = NULL;, w7 @- `3 T2 r
    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
, a* R: W$ H: k+ t- G: H4 X$ |    cout << "    roleName: " << roleName << endl;
% f6 q" y* D, R8 C    if(roleName) MEM_free(roleName);
% h8 w5 B5 H$ p& c# Q( B   
6 o7 k( {- h- u' ?6 ]    logical isDba = loggedInUser->isUserSystemAdministrator();2 j6 v5 @  x( Z) y& ~1 q3 F
    if(isDba == TRUE) cout << "    User is dba member "<< endl;
: j, J( C6 N0 `  M& ~8 g, J! V    if(isDba == FALSE) cout << "    User is not dba member "<< endl;      
% D. \' z1 _" a) q' L}[/mw_shl_code]
* `: X' l& u5 E5 P+ _1 i
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了