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

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:34:22

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

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

x
; L, [9 T  G1 o* r$ u* D. P/ L
Teamcenter二次开发源码分享: 获取当前用户信息
& p6 z7 l) R, F' f" R- E# [6 w7 s  j5 G
[mw_shl_code=cpp,true]#include <iostream>
# C9 F# w% k; B% s! y2 u#include <sa/group.h>. e/ G3 a' q: O- D2 g* P/ b
#include <sa/user.h>2 e1 R9 G5 [2 h
#include <TC/LoggedInUser.hxx>
7 o7 @' F& J( z/ G0 B$ I+ K$ a  m9 \/ C! E' `
using namespace Teamcenter;2 }$ i" _' N; i) Q3 d7 H: g
using namespace Core;$ D8 Q, ]" i* l/ w- ?
using namespace std;% R  [) }8 v" s+ B6 n) h

% V! ~& l* L4 D5 ^; f1 _# r, }static void reportCurrentLoginInfomation()
* s/ L# Y. q2 q& x( J+ {5 x{
' `8 y; u2 u- h/ L    int ifail = ITK_ok;
; M2 {" u; {5 V7 T    LoggedInUser* loggedInUser = LoggedInUser::getInstance();
' ?9 J* I1 b* T" W% L    ; }' \4 w7 a0 F( M8 c* L
    tag_t currentUserTag = loggedInUser->getCurrentUserTag();$ {. J5 ~* U7 s7 h7 `3 x  b
    cout << "    currentUserTag: " << currentUserTag << endl;, g" Y) t% H2 `0 P* N; n6 [
   
2 ?) O$ ]1 s- q2 z7 M    char *personName = NULL;1 a7 V9 m2 L3 i- Y3 g, K" q9 h
    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));4 J9 u+ K7 T$ O
    cout << "    personName: " << personName << endl;7 o+ \6 _4 P4 y1 k
    if(personName) MEM_free(personName);7 q* J0 R; F- ?% D# m0 d& t9 [7 z
    5 C+ J( G. ~, V6 w. H0 N, B
    const char* userID = loggedInUser->getCurrentUserID();
+ J2 f6 ^! |+ h$ A4 {7 N    cout << "    userID: " << userID << endl;
0 `/ o/ ], R- O9 y2 A7 g$ d! v" _: Z
    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();  h  M6 j% Q( H/ q
   
3 p: m6 A& [2 N4 e+ P5 O    char *groupName = NULL;
0 \! s  j- h! R    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));3 s: l& T) t* k
    cout << "    groupName: " << groupName << endl;
6 b# q9 G. ?7 s+ p    if(groupName) MEM_free(groupName);" W" L) e2 {$ X
/ L" L5 @0 F) G
    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
: u/ b- i, N, c; R& d/ n+ d    char *roleName = NULL;
; r5 a$ V" D* h1 Q: n    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
' m* r" Q6 D) w+ P, j    cout << "    roleName: " << roleName << endl;
, G& l! ^- l$ Q$ \5 q4 J* ^    if(roleName) MEM_free(roleName);
- v- L7 [( f) k& s7 P    ) s8 x9 G( j$ p4 H
    logical isDba = loggedInUser->isUserSystemAdministrator();
! z4 k9 D7 @( f9 w, s' I    if(isDba == TRUE) cout << "    User is dba member "<< endl;5 h% h. E, V/ d2 \& a8 H& @1 n, X
    if(isDba == FALSE) cout << "    User is not dba member "<< endl;      
# u" m: R' Y& H' X! t0 Q}[/mw_shl_code]" K, S1 J* T# M/ s$ \1 v. \- ?/ `
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了