History

Updates to Unix based UserInfo implementation.

ritchiecarroll committed 12 years ago

Commit bf22ae21 parent 2ab4c339 files · +284 −43Browse files

Showing the changes to Source/Libraries/GSF.Core/Identity/UnixUserInfo.cs (1 of 9 files). Show all

Unified · Split

Source/Libraries/GSF.Core/Identity/UnixUserInfo.cs+26−14
@@ -21,6 +21,9 @@ · 20 unmodified lines
2121 //
2222 //******************************************************************************************************
2323
24+// Undefine to use internally linked unmanaged functions (e.g., when Mono hosted in gsf service)
25+#define USE_SHARED_OBJECT
26+
2427 using System;
2528 using System.Collections;
2629 using System.Collections.Generic;
@@ -44,6 +47,12 @@ namespace GSF.Identity · 17 unmodified lines
4447 // Unix implementation of key UserInfo class elements
4548 internal class UnixUserInfo : IUserInfo
4649 {
50+#if USE_SHARED_OBJECT
51+ private const string IMPORT = "GSF.POSIX.so";
52+#else
53+ private const string IMPORT = "__Internal";
54+#endif
55+
4756 #region [ Members ]
4857
4958 // Nested Types
@@ -450,7 +459,7 @@ namespace GSF.Identity · 400 unmodified lines
450459 if (!m_isLocalAccount)
451460 return GetUserPropertyValueCollection("memberOf");
452461
453− return new string[0];
462+ return LocalGroups;
454463 }
455464 }
456465
@@ -482,6 +491,9 @@ namespace GSF.Identity · 25 unmodified lines
482491 if (string.IsNullOrWhiteSpace(userName))
483492 return m_parent.UserName;
484493
494+ if (userName.Contains(","))
495+ userName = userName.Split(',')[0];
496+
485497 return userName;
486498 }
487499 }
@@ -1271,51 +1283,51 @@ namespace GSF.Identity · 783 unmodified lines
12711283 #endregion
12721284
12731285 // AuthenticateUser function is PAM based, so it will support more than local users
1274− [DllImport("GSF.POSIX.so")]
1286+ [DllImport(IMPORT)]
12751287 private static extern int AuthenticateUser(string userName, string password);
12761288
12771289 // ChangeUserPassword function is PAM based, so it will support more than local users
1278− [DllImport("GSF.POSIX.so")]
1290+ [DllImport(IMPORT)]
12791291 private static extern int ChangeUserPassword(string userName, string oldPassword, string newPassword);
12801292
1281− [DllImport("GSF.POSIX.so")]
1293+ [DllImport(IMPORT)]
12821294 private static extern int GetLocalUserID(string userName, out uint userID);
12831295
12841296 // Preallocate outbound userName to 256 characters
1285− [DllImport("GSF.POSIX.so")]
1297+ [DllImport(IMPORT)]
12861298 private static extern int GetLocalUserName(uint uid, StringBuilder userName);
12871299
12881300 // Returns a char* that needs to marshaled to a .NET string
1289− [DllImport("GSF.POSIX.so")]
1301+ [DllImport(IMPORT)]
12901302 private static extern IntPtr GetLocalUserGecos(string userName);
12911303
12921304 // UserPasswordInformation structure contains only blittable types so it will be marshaled by reference
1293− [DllImport("GSF.POSIX.so")]
1305+ [DllImport(IMPORT)]
12941306 private static extern int GetLocalUserPasswordInformation(string userName, UserPasswordInformation userPasswordInfo, out AccountStatus status);
12951307
1296− [DllImport("GSF.POSIX.so")]
1308+ [DllImport(IMPORT)]
12971309 private static extern int SetLocalUserPassword(string userName, string password, string salt);
12981310
12991311 // Returns a char* that needs to be marshaled to a .NET string
1300− [DllImport("GSF.POSIX.so")]
1312+ [DllImport(IMPORT)]
13011313 private static extern IntPtr GetPasswordHash(string password, string salt);
13021314
1303− [DllImport("GSF.POSIX.so")]
1315+ [DllImport(IMPORT)]
13041316 private static extern int GetLocalUserGroupCount(string userName);
13051317
13061318 // Preallocate groupIDs as an unsigned integer array sized from GetLocalUserGroupCount
1307− [DllImport("GSF.POSIX.so")]
1319+ [DllImport(IMPORT)]
13081320 private static extern int GetLocalUserGroupIDs(string userName, int groupCount, ref uint[] groupsIDs);
13091321
1310− [DllImport("GSF.POSIX.so")]
1322+ [DllImport(IMPORT)]
13111323 private static extern int GetLocalGroupID(string groupName, out uint groupID);
13121324
13131325 // Preallocate outbound userName to 256 characters
1314− [DllImport("GSF.POSIX.so")]
1326+ [DllImport(IMPORT)]
13151327 private static extern int GetLocalGroupName(uint uid, StringBuilder groupName);
13161328
13171329 // Returns a char** that needs to be marshaled to a .NET string array
1318− [DllImport("GSF.POSIX.so")]
1330+ [DllImport(IMPORT)]
13191331 private static extern IntPtr GetLocalGroupMembers(string groupName);
13201332
13211333 #endregion

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t