PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:34:22

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

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

x

- Q8 z: q# C5 I" dTeamcenter二次开发源码分享: 获取当前用户信息1 d" _6 _) }5 w7 k- T" H( b
  V( s1 u7 K5 j. w
[mw_shl_code=cpp,true]#include <iostream>
# h6 A9 F: _0 J#include <sa/group.h>
2 S/ i# I) P  Y# |#include <sa/user.h>/ z' M4 ~, M  ?7 h  y7 B5 K
#include <TC/LoggedInUser.hxx>- K' S2 Q3 e( h$ _

9 G" s0 @! S1 l7 ^. gusing namespace Teamcenter;1 d4 J) A4 y8 k" t
using namespace Core;' t; D( W7 p5 G( c! _2 d/ A" d; x2 I
using namespace std;
; v1 t: \) M1 B5 O  C$ l. ^
$ \8 ]( I% ^: Vstatic void reportCurrentLoginInfomation()
- E% W+ c6 Q/ |8 t& g$ V{& s. ^' S2 L+ U2 ^, m3 Z. q
    int ifail = ITK_ok;
  B0 d6 L7 w  @    LoggedInUser* loggedInUser = LoggedInUser::getInstance();
1 _" j: H# m7 w$ N& @  \( y2 `   
* [0 Y2 P3 _2 |$ I7 D    tag_t currentUserTag = loggedInUser->getCurrentUserTag();
5 M% }5 W7 p% f  g( h5 G; l    cout << "    currentUserTag: " << currentUserTag << endl;2 `1 A& p: W; x' M3 N* q
   
5 I" ^! X9 Z& s$ o    char *personName = NULL;
$ o% |9 g. v8 Y* N, f. p7 e7 P5 R    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));# b0 C# F* x! B  l* |4 a8 T1 m
    cout << "    personName: " << personName << endl;5 ?, u$ I) n. u2 S( }; n8 u' a% Q) P
    if(personName) MEM_free(personName);
0 v% s0 a+ z9 [   
; ^& G" @/ S6 D7 ]' G& U    const char* userID = loggedInUser->getCurrentUserID();
2 C& W% U  x( n! ?    cout << "    userID: " << userID << endl;) f; V' s& a3 i* G
+ M& r/ U& @, ~. m8 |( y+ P; Y
    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();" h8 D$ o" I+ v7 U% `
    , N2 M9 {$ C  W8 F
    char *groupName = NULL;
+ i0 ]! {1 W0 F! T( ^) P    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));1 g& y: W3 G# V
    cout << "    groupName: " << groupName << endl;) ?- H* k) K% d5 P5 D
    if(groupName) MEM_free(groupName);3 K$ m; C) @+ Y$ F6 R4 `; e1 w

! i. t& {9 N) w) s    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
: I( b1 c. \$ K. [$ u( ]    char *roleName = NULL;
9 m: q: K. G& n( Y    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
9 B. U8 \# v' ^& V    cout << "    roleName: " << roleName << endl;
$ W* q6 L" i1 P" y    if(roleName) MEM_free(roleName);
* J. ^  S2 I, \8 H. A; p. R1 M   
3 p) B9 ]) b3 J7 [, ]    logical isDba = loggedInUser->isUserSystemAdministrator();
# `; _) p" T9 ]) T0 f    if(isDba == TRUE) cout << "    User is dba member "<< endl;+ c% p- E5 g5 U* Y2 w7 u
    if(isDba == FALSE) cout << "    User is not dba member "<< endl;       + L# [# @' w( Z$ W" I+ y
}[/mw_shl_code]
( ~, a2 k5 c6 D
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了