// todo надо ли вообще здесь такую реализацию public static TmUserInfo GetUserInfo(IntPtr cfCid, string serverName, string serverType) { var nativeUserInfoSize = Marshal.SizeOf(typeof(TmNativeDefs.TExtendedUserInfo)); var nativeUserInfoPtr = Marshal.AllocHGlobal(nativeUserInfoSize); var fetchResult = Native.CfsGetExtendedUserData(cfCid, serverType, serverName, nativeUserInfoPtr, (uint)nativeUserInfoSize); if (fetchResult == 0) { return(null); } var nativeUserInfo = Marshal.PtrToStructure <TmNativeDefs.TExtendedUserInfo>(nativeUserInfoPtr); return(new TmUserInfo(nativeUserInfo.UserId, Encoding.GetEncoding(1251).GetString(nativeUserInfo.UserName).Trim('\0'), string.Empty, // todo надо ли сделать получать категорию Encoding.GetEncoding(1251).GetString(nativeUserInfo.KeyId).Trim('\0'), nativeUserInfo.Group, nativeUserInfo.Rights)); }
public static TmUserInfo GetUserInfo(int tmCid, string serverName) { var nativeUserInfoSize = Marshal.SizeOf(typeof(TmNativeDefs.TExtendedUserInfo)); var nativeUserInfoPtr = Marshal.AllocHGlobal(nativeUserInfoSize); var cfCid = Native.TmcGetCfsHandle(tmCid); if (cfCid == IntPtr.Zero) { return(null); } var fetchResult = Native.CfsGetExtendedUserData(cfCid, "tms$", serverName, nativeUserInfoPtr, (uint)nativeUserInfoSize); if (fetchResult == 0) { return(null); } var extendedUserInfo = Marshal.PtrToStructure <TmNativeDefs.TExtendedUserInfo>(nativeUserInfoPtr); var userInfo = new TmNativeDefs.TUserInfo(); if (!Native.TmcGetUserInfo(tmCid, 0, ref userInfo)) { return(null); } return(new TmUserInfo(extendedUserInfo.UserId, Encoding.GetEncoding(1251).GetString(extendedUserInfo.UserName).Trim('\0'), Encoding.GetEncoding(1251).GetString(userInfo.UserCategory).Trim('\0'), Encoding.GetEncoding(1251).GetString(extendedUserInfo.KeyId).Trim('\0'), extendedUserInfo.Group, extendedUserInfo.Rights)); }