[ros-diffs] [ekohl] 33890: - Group properties: Display the SID of well-known members. - User properties: Store changes to the general settings.

ekohl at svn.reactos.org ekohl at svn.reactos.org
Sun Jun 8 00:31:25 CEST 2008


Author: ekohl
Date: Sat Jun  7 17:31:24 2008
New Revision: 33890

URL: http://svn.reactos.org/svn/reactos?rev=33890&view=rev
Log:
- Group properties: Display the SID of well-known members.
- User properties: Store changes to the general settings.

Modified:
    trunk/reactos/dll/cpl/usrmgr/groupprops.c
    trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc
    trunk/reactos/dll/cpl/usrmgr/userprops.c
    trunk/reactos/dll/cpl/usrmgr/users.c
    trunk/reactos/dll/cpl/usrmgr/usrmgr.h
    trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild

Modified: trunk/reactos/dll/cpl/usrmgr/groupprops.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/groupprops.c?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/groupprops.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/groupprops.c [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -8,6 +8,56 @@
  */
 
 #include "usrmgr.h"
+
+typedef struct _GENERAL_GROUP_DATA
+{
+    TCHAR szGroupName[1];
+} GENERAL_GROUP_DATA, *PGENERAL_GROUP_DATA;
+
+
+static VOID
+GetTextSid(PSID pSid,
+           LPTSTR pTextSid)
+{
+    PSID_IDENTIFIER_AUTHORITY psia;
+    DWORD dwSubAuthorities;
+    DWORD dwSidRev = SID_REVISION;
+    DWORD dwCounter;
+    DWORD dwSidSize;
+
+    psia = GetSidIdentifierAuthority(pSid);
+
+    dwSubAuthorities = *GetSidSubAuthorityCount(pSid);
+
+    dwSidSize = wsprintf(pTextSid, TEXT("S-%lu-"), dwSidRev);
+
+    if ((psia->Value[0] != 0) || (psia->Value[1] != 0))
+    {
+        dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
+                              TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),
+                              (USHORT)psia->Value[0],
+                              (USHORT)psia->Value[1],
+                              (USHORT)psia->Value[2],
+                              (USHORT)psia->Value[3],
+                              (USHORT)psia->Value[4],
+                              (USHORT)psia->Value[5]);
+    }
+    else
+    {
+        dwSidSize += wsprintf(pTextSid + lstrlen(pTextSid),
+                              TEXT("%lu"),
+                              (ULONG)(psia->Value[5]) +
+                              (ULONG)(psia->Value[4] <<  8) +
+                              (ULONG)(psia->Value[3] << 16) +
+                              (ULONG)(psia->Value[2] << 24));
+    }
+
+    for (dwCounter = 0 ; dwCounter < dwSubAuthorities ; dwCounter++)
+    {
+        dwSidSize += wsprintf(pTextSid + dwSidSize, TEXT("-%lu"),
+                              *GetSidSubAuthority(pSid, dwCounter));
+    }
+}
 
 
 static VOID
@@ -25,6 +75,8 @@
     RECT rect;
     HIMAGELIST hImgList;
     HICON hIcon;
+    TCHAR szGroupName[256];
+
 
     hwndLV = GetDlgItem(hwndDlg, IDC_GROUP_GENERAL_MEMBERS);
 
@@ -70,6 +122,21 @@
         lvi.iImage = (membersInfo[i].lgrmi1_sidusage == SidTypeGroup ||
                       membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup) ? 1 : 0;
 
+        if (membersInfo[i].lgrmi1_sidusage == SidTypeWellKnownGroup)
+        {
+            TCHAR szSid[256];
+
+            GetTextSid(membersInfo[i].lgrmi1_sid, szSid);
+
+            wsprintf(szGroupName,
+                     TEXT("%s\\%s (%s)"),
+                     
+                     membersInfo[i].lgrmi1_name,
+                     szSid);
+
+            lvi.pszText = szGroupName;
+        }
+
         (void)ListView_InsertItem(hwndLV, &lvi);
     }
 
@@ -118,7 +185,7 @@
 }
 
 
-VOID
+BOOL
 GroupProperties(HWND hwndDlg)
 {
     PROPSHEETPAGE psp[1];
@@ -130,7 +197,7 @@
     hwndLV = GetDlgItem(hwndDlg, IDC_GROUPS_LIST);
     nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
     if (nItem == -1)
-        return;
+        return FALSE;
 
     /* Get the new user name */
     ListView_GetItemText(hwndLV,
@@ -151,5 +218,5 @@
 
     InitPropSheetPage(&psp[0], IDD_GROUP_GENERAL, (DLGPROC)GroupGeneralPageProc, szGroupName);
 
-    PropertySheet(&psh);
-}
+    return (PropertySheet(&psh) == IDOK);
+}

Modified: trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/lang/en-US.rc [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -50,7 +50,7 @@
     AUTOCHECKBOX    "User cannot change the password",IDC_USER_GENERAL_CANNOT_CHANGE,7,95,210,10
     AUTOCHECKBOX    "Password never expires",IDC_USER_GENERAL_NEVER_EXPIRES,7,108,210,10
     AUTOCHECKBOX    "Account is disabled",IDC_USER_GENERAL_DISABLED,7,121,210,10
-    AUTOCHECKBOX    "Account is locked",IDC_USER_GENERAL_LOCKED,7,134,210,10,WS_DISABLED
+    AUTOCHECKBOX    "Account is locked",IDC_USER_GENERAL_LOCKED,7,134,210,10
 END
 
 

Modified: trunk/reactos/dll/cpl/usrmgr/userprops.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/userprops.c?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/userprops.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/userprops.c [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -8,6 +8,16 @@
  */
 
 #include "usrmgr.h"
+
+typedef struct _GENERAL_USER_DATA
+{
+    DWORD dwFlags;
+    DWORD dwPasswordExpired;
+    TCHAR szUserName[1];
+} GENERAL_USER_DATA, *PGENERAL_USER_DATA;
+
+#define VALID_GENERAL_FLAGS (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD | UF_ACCOUNTDISABLE | UF_LOCKOUT)
+
 
 
 static VOID
@@ -187,48 +197,116 @@
 
 static VOID
 UpdateUserOptions(HWND hwndDlg,
-                  PUSER_INFO_3 userInfo,
+                  PGENERAL_USER_DATA pUserData,
                   BOOL bInit)
 {
     EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE),
-                 !userInfo->usri3_password_expired);
+                 !pUserData->dwPasswordExpired);
     EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES),
-                 !userInfo->usri3_password_expired);
+                 !pUserData->dwPasswordExpired);
     EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE),
-                 (userInfo->usri3_flags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
+                 (pUserData->dwFlags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
+
+    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_LOCKED),
+                 (pUserData->dwFlags & UF_LOCKOUT) != 0);
 
     if (bInit)
     {
         CheckDlgButton(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE,
-                       userInfo->usri3_password_expired ? BST_CHECKED : BST_UNCHECKED);
+                       pUserData->dwPasswordExpired ? BST_CHECKED : BST_UNCHECKED);
 
         CheckDlgButton(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE,
-                       (userInfo->usri3_flags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
+                       (pUserData->dwFlags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
 
         CheckDlgButton(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES,
-                       (userInfo->usri3_flags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
+                       (pUserData->dwFlags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
 
         CheckDlgButton(hwndDlg, IDC_USER_GENERAL_DISABLED,
-                       (userInfo->usri3_flags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
+                       (pUserData->dwFlags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
+
+        CheckDlgButton(hwndDlg, IDC_USER_GENERAL_LOCKED,
+                       (pUserData->dwFlags & UF_LOCKOUT) ? BST_CHECKED : BST_UNCHECKED);
     }
 }
 
 
 static VOID
-GetUserData(HWND hwndDlg, LPTSTR lpUserName, PUSER_INFO_3 *usrInfo)
-{
-    PUSER_INFO_3 userInfo = NULL;
-
-    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, lpUserName);
-
-    NetUserGetInfo(NULL, lpUserName, 3, (LPBYTE*)&userInfo);
-
-    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, userInfo->usri3_full_name);
-    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, userInfo->usri3_comment);
-
-    UpdateUserOptions(hwndDlg, userInfo, TRUE);
-
-    *usrInfo = userInfo;
+GetGeneralUserData(HWND hwndDlg,
+                   PGENERAL_USER_DATA pUserData)
+{
+    PUSER_INFO_3 pUserInfo = NULL;
+
+    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, pUserData->szUserName);
+
+    NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
+
+    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pUserInfo->usri3_full_name);
+    SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pUserInfo->usri3_comment);
+
+    pUserData->dwFlags = pUserInfo->usri3_flags;
+    pUserData->dwPasswordExpired = pUserInfo->usri3_password_expired;
+
+    NetApiBufferFree(pUserInfo);
+
+    UpdateUserOptions(hwndDlg, pUserData, TRUE);
+}
+
+
+static BOOL
+SetGeneralUserData(HWND hwndDlg,
+                   PGENERAL_USER_DATA pUserData)
+{
+    PUSER_INFO_3 pUserInfo = NULL;
+    LPTSTR pszFullName = NULL;
+    LPTSTR pszComment = NULL;
+    NET_API_STATUS status;
+    DWORD dwIndex;
+    INT nLength;
+
+    NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
+
+    pUserInfo->usri3_flags =
+        (pUserData->dwFlags & VALID_GENERAL_FLAGS) |
+        (pUserInfo->usri3_flags & ~VALID_GENERAL_FLAGS);
+
+    pUserInfo->usri3_password_expired = pUserData->dwPasswordExpired;
+
+    nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FULL_NAME));
+    if (nLength == 0)
+    {
+        pUserInfo->usri3_full_name = NULL;
+    }
+    else
+    {
+        pszFullName = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
+        GetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pszFullName, nLength + 1);
+        pUserInfo->usri3_full_name = pszFullName;
+    }
+
+    nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_DESCRIPTION));
+    if (nLength == 0)
+    {
+        pUserInfo->usri3_full_name = NULL;
+    }
+    else
+    {
+        pszComment = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
+        GetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pszComment, nLength + 1);
+        pUserInfo->usri3_comment = pszComment;
+    }
+
+    status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
+    if (status != NERR_Success)
+    {
+        DebugPrintf(_T("Status: %lu  Index: %lu"), status, dwIndex);
+    }
+
+    if (pszFullName)
+        HeapFree(GetProcessHeap(), 0, pszFullName);
+
+    NetApiBufferFree(pUserInfo);
+
+    return (status == NERR_Success);
 }
 
 
@@ -238,52 +316,72 @@
                     WPARAM wParam,
                     LPARAM lParam)
 {
-    PUSER_INFO_3 userInfo;
+    PGENERAL_USER_DATA pUserData;
 
     UNREFERENCED_PARAMETER(lParam);
     UNREFERENCED_PARAMETER(wParam);
     UNREFERENCED_PARAMETER(hwndDlg);
 
-    userInfo = (PUSER_INFO_3)GetWindowLongPtr(hwndDlg, DWLP_USER);
+    pUserData= (PGENERAL_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
 
     switch (uMsg)
     {
         case WM_INITDIALOG:
-            GetUserData(hwndDlg,
-                        (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam,
-                        &userInfo);
-            SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)userInfo);
+            pUserData = (PGENERAL_USER_DATA)HeapAlloc(GetProcessHeap(),
+                                                      HEAP_ZERO_MEMORY,
+                                                      sizeof(GENERAL_USER_DATA) + 
+                                                      lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
+            lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
+
+            GetGeneralUserData(hwndDlg,
+                               pUserData);
+
+            SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
             break;
 
         case WM_COMMAND:
             switch (LOWORD(wParam))
             {
                 case IDC_USER_GENERAL_FORCE_CHANGE:
-                    userInfo->usri3_password_expired = !userInfo->usri3_password_expired;
-                    UpdateUserOptions(hwndDlg, userInfo, FALSE);
+                    pUserData->dwPasswordExpired = !pUserData->dwPasswordExpired;
+                    UpdateUserOptions(hwndDlg, pUserData, FALSE);
+                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     break;
 
                 case IDC_USER_GENERAL_CANNOT_CHANGE:
-                    userInfo->usri3_flags ^= UF_PASSWD_CANT_CHANGE;
-                    UpdateUserOptions(hwndDlg, userInfo, FALSE);
+                    pUserData->dwFlags ^= UF_PASSWD_CANT_CHANGE;
+                    UpdateUserOptions(hwndDlg, pUserData, FALSE);
+                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     break;
 
                 case IDC_USER_GENERAL_NEVER_EXPIRES:
-                    userInfo->usri3_flags ^= UF_DONT_EXPIRE_PASSWD;
-                    UpdateUserOptions(hwndDlg, userInfo, FALSE);
+                    pUserData->dwFlags ^= UF_DONT_EXPIRE_PASSWD;
+                    UpdateUserOptions(hwndDlg, pUserData, FALSE);
+                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     break;
 
                 case IDC_USER_GENERAL_DISABLED:
-                    userInfo->usri3_flags ^= UF_ACCOUNTDISABLE;
+                    pUserData->dwFlags ^= UF_ACCOUNTDISABLE;
+                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     break;
 
                 case IDC_USER_GENERAL_LOCKED:
+                    pUserData->dwFlags ^= UF_LOCKOUT;
+                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     break;
             }
             break;
 
+        case WM_NOTIFY:
+            if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
+            {
+                SetGeneralUserData(hwndDlg, pUserData);
+                return TRUE;
+            }
+            break;
+
         case WM_DESTROY:
-            NetApiBufferFree(userInfo);
+            HeapFree(GetProcessHeap(), 0, pUserData);
             break;
     }
 
@@ -304,7 +402,7 @@
 }
 
 
-VOID
+BOOL
 UserProperties(HWND hwndDlg)
 {
     PROPSHEETPAGE psp[3];
@@ -316,7 +414,7 @@
     hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
     nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
     if (nItem == -1)
-        return;
+        return FALSE;
 
     /* Get the new user name */
     ListView_GetItemText(hwndLV,
@@ -339,5 +437,5 @@
     InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, (DLGPROC)UserMembershipPageProc, szUserName);
     InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc, szUserName);
 
-    PropertySheet(&psh);
-}
+    return (PropertySheet(&psh) == IDOK);
+}

Modified: trunk/reactos/dll/cpl/usrmgr/users.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/users.c?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/users.c [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -596,6 +596,46 @@
 }
 
 
+static VOID
+UpdateUserProperties(HWND hwndDlg)
+{
+    TCHAR szUserName[UNLEN];
+    INT iItem;
+    HWND hwndLV;
+    NET_API_STATUS status;
+    PUSER_INFO_2 pUserInfo = NULL;
+    LV_ITEM lvi;
+
+    hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
+    iItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
+    if (iItem == -1)
+        return;
+
+    /* Get the new user name */
+    ListView_GetItemText(hwndLV,
+                         iItem, 0,
+                         szUserName,
+                         UNLEN);
+
+    status = NetUserGetInfo(NULL, szUserName, 2, (LPBYTE*)&pUserInfo);
+
+    memset(&lvi, 0x00, sizeof(lvi));
+    lvi.iItem = iItem;
+    lvi.iSubItem = 0;
+    lvi.mask = LVIF_IMAGE;
+    lvi.iImage = (pUserInfo->usri2_flags & UF_ACCOUNTDISABLE) ? 1 : 0;
+    (void)ListView_SetItem(hwndLV, &lvi);
+
+    ListView_SetItemText(hwndLV, iItem, 1,
+                         pUserInfo->usri2_full_name);
+
+    ListView_SetItemText(hwndLV, iItem, 2,
+                         pUserInfo->usri2_comment);
+
+    NetApiBufferFree(pUserInfo);
+}
+
+
 INT_PTR CALLBACK
 UsersPageProc(HWND hwndDlg,
               UINT uMsg,
@@ -646,7 +686,10 @@
                     break;
 
                 case IDM_USER_PROPERTIES:
-                    UserProperties(hwndDlg);
+                    if (UserProperties(hwndDlg))
+                    {
+                        UpdateUserProperties(hwndDlg);
+                    }
                     break;
             }
             break;

Modified: trunk/reactos/dll/cpl/usrmgr/usrmgr.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/usrmgr.h?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/usrmgr.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/usrmgr.h [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -30,7 +30,7 @@
 INT_PTR CALLBACK ExtraPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 /* groupprops.c */
-VOID
+BOOL
 GroupProperties(HWND hwndDlg);
 
 /* misc.c */
@@ -43,7 +43,7 @@
                  LPTSTR lpAccountName);
 
 /* userprops.c */
-VOID
+BOOL
 UserProperties(HWND hwndDlg);
 
 #endif /* __CPL_DESK_H__ */

Modified: trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild?rev=33890&r1=33889&r2=33890&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/usrmgr/usrmgr.rbuild [iso-8859-1] Sat Jun  7 17:31:24 2008
@@ -7,6 +7,7 @@
 	<define name="_WIN32_WINNT">0x501</define>
 	<define name="WINVER">0x609</define>
 	<library>kernel32</library>
+	<library>advapi32</library>
 	<library>user32</library>
 	<library>gdi32</library>
 	<library>comctl32</library>



More information about the Ros-diffs mailing list