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 | using System; | 27 | using System; |
| 25 | using System.Collections; | 28 | using System.Collections; |
| 26 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
| @@ -44,6 +47,12 @@ namespace GSF.Identity · 17 unmodified lines | |||
| 44 | // Unix implementation of key UserInfo class elements | 47 | // Unix implementation of key UserInfo class elements |
| 45 | internal class UnixUserInfo : IUserInfo | 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 | #region [ Members ] | 56 | #region [ Members ] |
| 48 | 57 | ||
| 49 | // Nested Types | 58 | // Nested Types |
| @@ -450,7 +459,7 @@ namespace GSF.Identity · 400 unmodified lines | |||
| 450 | if (!m_isLocalAccount) | 459 | if (!m_isLocalAccount) |
| 451 | return GetUserPropertyValueCollection("memberOf"); | 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 | if (string.IsNullOrWhiteSpace(userName)) | 491 | if (string.IsNullOrWhiteSpace(userName)) |
| 483 | return m_parent.UserName; | 492 | return m_parent.UserName; |
| 484 | 493 | ||
| 494 | if (userName.Contains(",")) | ||
| 495 | userName = userName.Split(',')[0]; | ||
| 496 | |||
| 485 | return userName; | 497 | return userName; |
| 486 | } | 498 | } |
| 487 | } | 499 | } |
| @@ -1271,51 +1283,51 @@ namespace GSF.Identity · 783 unmodified lines | |||
| 1271 | #endregion | 1283 | #endregion |
| 1272 | 1284 | ||
| 1273 | // AuthenticateUser function is PAM based, so it will support more than local users | 1285 | // AuthenticateUser function is PAM based, so it will support more than local users |
| 1274 | [DllImport("GSF.POSIX.so")] | 1286 | [DllImport(IMPORT)] |
| 1275 | private static extern int AuthenticateUser(string userName, string password); | 1287 | private static extern int AuthenticateUser(string userName, string password); |
| 1276 | 1288 | ||
| 1277 | // ChangeUserPassword function is PAM based, so it will support more than local users | 1289 | // ChangeUserPassword function is PAM based, so it will support more than local users |
| 1278 | [DllImport("GSF.POSIX.so")] | 1290 | [DllImport(IMPORT)] |
| 1279 | private static extern int ChangeUserPassword(string userName, string oldPassword, string newPassword); | 1291 | private static extern int ChangeUserPassword(string userName, string oldPassword, string newPassword); |
| 1280 | 1292 | ||
| 1281 | [DllImport("GSF.POSIX.so")] | 1293 | [DllImport(IMPORT)] |
| 1282 | private static extern int GetLocalUserID(string userName, out uint userID); | 1294 | private static extern int GetLocalUserID(string userName, out uint userID); |
| 1283 | 1295 | ||
| 1284 | // Preallocate outbound userName to 256 characters | 1296 | // Preallocate outbound userName to 256 characters |
| 1285 | [DllImport("GSF.POSIX.so")] | 1297 | [DllImport(IMPORT)] |
| 1286 | private static extern int GetLocalUserName(uint uid, StringBuilder userName); | 1298 | private static extern int GetLocalUserName(uint uid, StringBuilder userName); |
| 1287 | 1299 | ||
| 1288 | // Returns a char* that needs to marshaled to a .NET string | 1300 | // Returns a char* that needs to marshaled to a .NET string |
| 1289 | [DllImport("GSF.POSIX.so")] | 1301 | [DllImport(IMPORT)] |
| 1290 | private static extern IntPtr GetLocalUserGecos(string userName); | 1302 | private static extern IntPtr GetLocalUserGecos(string userName); |
| 1291 | 1303 | ||
| 1292 | // UserPasswordInformation structure contains only blittable types so it will be marshaled by reference | 1304 | // UserPasswordInformation structure contains only blittable types so it will be marshaled by reference |
| 1293 | [DllImport("GSF.POSIX.so")] | 1305 | [DllImport(IMPORT)] |
| 1294 | private static extern int GetLocalUserPasswordInformation(string userName, UserPasswordInformation userPasswordInfo, out AccountStatus status); | 1306 | private static extern int GetLocalUserPasswordInformation(string userName, UserPasswordInformation userPasswordInfo, out AccountStatus status); |
| 1295 | 1307 | ||
| 1296 | [DllImport("GSF.POSIX.so")] | 1308 | [DllImport(IMPORT)] |
| 1297 | private static extern int SetLocalUserPassword(string userName, string password, string salt); | 1309 | private static extern int SetLocalUserPassword(string userName, string password, string salt); |
| 1298 | 1310 | ||
| 1299 | // Returns a char* that needs to be marshaled to a .NET string | 1311 | // Returns a char* that needs to be marshaled to a .NET string |
| 1300 | [DllImport("GSF.POSIX.so")] | 1312 | [DllImport(IMPORT)] |
| 1301 | private static extern IntPtr GetPasswordHash(string password, string salt); | 1313 | private static extern IntPtr GetPasswordHash(string password, string salt); |
| 1302 | 1314 | ||
| 1303 | [DllImport("GSF.POSIX.so")] | 1315 | [DllImport(IMPORT)] |
| 1304 | private static extern int GetLocalUserGroupCount(string userName); | 1316 | private static extern int GetLocalUserGroupCount(string userName); |
| 1305 | 1317 | ||
| 1306 | // Preallocate groupIDs as an unsigned integer array sized from GetLocalUserGroupCount | 1318 | // Preallocate groupIDs as an unsigned integer array sized from GetLocalUserGroupCount |
| 1307 | [DllImport("GSF.POSIX.so")] | 1319 | [DllImport(IMPORT)] |
| 1308 | private static extern int GetLocalUserGroupIDs(string userName, int groupCount, ref uint[] groupsIDs); | 1320 | private static extern int GetLocalUserGroupIDs(string userName, int groupCount, ref uint[] groupsIDs); |
| 1309 | 1321 | ||
| 1310 | [DllImport("GSF.POSIX.so")] | 1322 | [DllImport(IMPORT)] |
| 1311 | private static extern int GetLocalGroupID(string groupName, out uint groupID); | 1323 | private static extern int GetLocalGroupID(string groupName, out uint groupID); |
| 1312 | 1324 | ||
| 1313 | // Preallocate outbound userName to 256 characters | 1325 | // Preallocate outbound userName to 256 characters |
| 1314 | [DllImport("GSF.POSIX.so")] | 1326 | [DllImport(IMPORT)] |
| 1315 | private static extern int GetLocalGroupName(uint uid, StringBuilder groupName); | 1327 | private static extern int GetLocalGroupName(uint uid, StringBuilder groupName); |
| 1316 | 1328 | ||
| 1317 | // Returns a char** that needs to be marshaled to a .NET string array | 1329 | // Returns a char** that needs to be marshaled to a .NET string array |
| 1318 | [DllImport("GSF.POSIX.so")] | 1330 | [DllImport(IMPORT)] |
| 1319 | private static extern IntPtr GetLocalGroupMembers(string groupName); | 1331 | private static extern IntPtr GetLocalGroupMembers(string groupName); |
| 1320 | 1332 | ||
| 1321 | #endregion | 1333 | #endregion |