Showing the changes to Source/Libraries/GSF.Core/Identity/UnixUserInfo.cs (1 of 9 files). Show all
Unified · Split
| @@ -21,6 +21,9 @@ · 20 unmodified lines | ||
| 21 | 21 | // |
| 22 | 22 | //****************************************************************************************************** |
| 23 | 23 | |
| 24 | +// Undefine to use internally linked unmanaged functions (e.g., when Mono hosted in gsf service) | |
| 25 | +#define USE_SHARED_OBJECT | |
| 26 | + | |
| 24 | 27 | using System; |
| 25 | 28 | using System.Collections; |
| 26 | 29 | using System.Collections.Generic; |
| @@ -44,6 +47,12 @@ namespace GSF.Identity · 17 unmodified lines | ||
| 44 | 47 | // Unix implementation of key UserInfo class elements |
| 45 | 48 | internal class UnixUserInfo : IUserInfo |
| 46 | 49 | { |
| 50 | +#if USE_SHARED_OBJECT | |
| 51 | + private const string IMPORT = "GSF.POSIX.so"; | |
| 52 | +#else | |
| 53 | + private const string IMPORT = "__Internal"; | |
| 54 | +#endif | |
| 55 | + | |
| 47 | 56 | #region [ Members ] |
| 48 | 57 | |
| 49 | 58 | // Nested Types |
| @@ -450,7 +459,7 @@ namespace GSF.Identity · 400 unmodified lines | ||
| 450 | 459 | if (!m_isLocalAccount) |
| 451 | 460 | return GetUserPropertyValueCollection("memberOf"); |
| 452 | 461 | |
| 453 | − return new string[0]; | |
| 462 | + return LocalGroups; | |
| 454 | 463 | } |
| 455 | 464 | } |
| 456 | 465 | |
| @@ -482,6 +491,9 @@ namespace GSF.Identity · 25 unmodified lines | ||
| 482 | 491 | if (string.IsNullOrWhiteSpace(userName)) |
| 483 | 492 | return m_parent.UserName; |
| 484 | 493 | |
| 494 | + if (userName.Contains(",")) | |
| 495 | + userName = userName.Split(',')[0]; | |
| 496 | + | |
| 485 | 497 | return userName; |
| 486 | 498 | } |
| 487 | 499 | } |
| @@ -1271,51 +1283,51 @@ namespace GSF.Identity · 783 unmodified lines | ||
| 1271 | 1283 | #endregion |
| 1272 | 1284 | |
| 1273 | 1285 | // AuthenticateUser function is PAM based, so it will support more than local users |
| 1274 | − [DllImport("GSF.POSIX.so")] | |
| 1286 | + [DllImport(IMPORT)] | |
| 1275 | 1287 | private static extern int AuthenticateUser(string userName, string password); |
| 1276 | 1288 | |
| 1277 | 1289 | // ChangeUserPassword function is PAM based, so it will support more than local users |
| 1278 | − [DllImport("GSF.POSIX.so")] | |
| 1290 | + [DllImport(IMPORT)] | |
| 1279 | 1291 | private static extern int ChangeUserPassword(string userName, string oldPassword, string newPassword); |
| 1280 | 1292 | |
| 1281 | − [DllImport("GSF.POSIX.so")] | |
| 1293 | + [DllImport(IMPORT)] | |
| 1282 | 1294 | private static extern int GetLocalUserID(string userName, out uint userID); |
| 1283 | 1295 | |
| 1284 | 1296 | // Preallocate outbound userName to 256 characters |
| 1285 | − [DllImport("GSF.POSIX.so")] | |
| 1297 | + [DllImport(IMPORT)] | |
| 1286 | 1298 | private static extern int GetLocalUserName(uint uid, StringBuilder userName); |
| 1287 | 1299 | |
| 1288 | 1300 | // Returns a char* that needs to marshaled to a .NET string |
| 1289 | − [DllImport("GSF.POSIX.so")] | |
| 1301 | + [DllImport(IMPORT)] | |
| 1290 | 1302 | private static extern IntPtr GetLocalUserGecos(string userName); |
| 1291 | 1303 | |
| 1292 | 1304 | // UserPasswordInformation structure contains only blittable types so it will be marshaled by reference |
| 1293 | − [DllImport("GSF.POSIX.so")] | |
| 1305 | + [DllImport(IMPORT)] | |
| 1294 | 1306 | private static extern int GetLocalUserPasswordInformation(string userName, UserPasswordInformation userPasswordInfo, out AccountStatus status); |
| 1295 | 1307 | |
| 1296 | − [DllImport("GSF.POSIX.so")] | |
| 1308 | + [DllImport(IMPORT)] | |
| 1297 | 1309 | private static extern int SetLocalUserPassword(string userName, string password, string salt); |
| 1298 | 1310 | |
| 1299 | 1311 | // Returns a char* that needs to be marshaled to a .NET string |
| 1300 | − [DllImport("GSF.POSIX.so")] | |
| 1312 | + [DllImport(IMPORT)] | |
| 1301 | 1313 | private static extern IntPtr GetPasswordHash(string password, string salt); |
| 1302 | 1314 | |
| 1303 | − [DllImport("GSF.POSIX.so")] | |
| 1315 | + [DllImport(IMPORT)] | |
| 1304 | 1316 | private static extern int GetLocalUserGroupCount(string userName); |
| 1305 | 1317 | |
| 1306 | 1318 | // Preallocate groupIDs as an unsigned integer array sized from GetLocalUserGroupCount |
| 1307 | − [DllImport("GSF.POSIX.so")] | |
| 1319 | + [DllImport(IMPORT)] | |
| 1308 | 1320 | private static extern int GetLocalUserGroupIDs(string userName, int groupCount, ref uint[] groupsIDs); |
| 1309 | 1321 | |
| 1310 | − [DllImport("GSF.POSIX.so")] | |
| 1322 | + [DllImport(IMPORT)] | |
| 1311 | 1323 | private static extern int GetLocalGroupID(string groupName, out uint groupID); |
| 1312 | 1324 | |
| 1313 | 1325 | // Preallocate outbound userName to 256 characters |
| 1314 | − [DllImport("GSF.POSIX.so")] | |
| 1326 | + [DllImport(IMPORT)] | |
| 1315 | 1327 | private static extern int GetLocalGroupName(uint uid, StringBuilder groupName); |
| 1316 | 1328 | |
| 1317 | 1329 | // Returns a char** that needs to be marshaled to a .NET string array |
| 1318 | − [DllImport("GSF.POSIX.so")] | |
| 1330 | + [DllImport(IMPORT)] | |
| 1319 | 1331 | private static extern IntPtr GetLocalGroupMembers(string groupName); |
| 1320 | 1332 | |
| 1321 | 1333 | #endregion |