Kaynağa Gözat

HPCC-21263 Return expiration date in WsAccess.UserInfoEditInput

Create a function to retrieve expiration date information and
return it in WsAccess.UserInfoEditInput.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 6 yıl önce
ebeveyn
işleme
9953a3b18c

+ 2 - 1
esp/scm/ws_access.ecm

@@ -233,6 +233,7 @@ ESPresponse UserInfoEditInputResponse
     string firstname;
     string lastname;
     [min_ver("1.10")] string employeeID;
+    [min_ver("1.12")] string PasswordExpiration;
 };
 
 ESPrequest UserInfoEditRequest
@@ -976,7 +977,7 @@ ESPresponse [nil_remove] UserAccountExportResponse
     [http_content("application/octet-stream")] binary Result;
 };
 
-ESPservice [version("1.11"), auth_feature("NONE"), exceptions_inline("./smc_xslt/exceptions.xslt")] ws_access
+ESPservice [version("1.12"), auth_feature("NONE"), exceptions_inline("./smc_xslt/exceptions.xslt")] ws_access
 {
     ESPmethod [client_xslt("/esp/xslt/access_users.xslt")] Users(UserRequest, UserResponse);
     ESPmethod [client_xslt("/esp/xslt/access_useredit.xslt")] UserEdit(UserEditRequest, UserEditResponse);

+ 29 - 18
esp/services/ws_access/ws_accessService.cpp

@@ -457,23 +457,7 @@ bool Cws_accessEx::onUsers(IEspContext &context, IEspUserRequest &req, IEspUserR
                 if (version >= 1.07)
                 {
                     StringBuffer sb;
-                    switch (usr->getPasswordDaysRemaining())//-1 if expired, -2 if never expires
-                    {
-                    case scPasswordExpired:
-                        sb.set("Expired");
-                        break;
-                    case scPasswordNeverExpires:
-                        sb.set("Never");
-                        break;
-                    default:
-                        {
-                            CDateTime dt;
-                            usr->getPasswordExpiration(dt);
-                            dt.getDateString(sb);
-                            break;
-                        }
-                    }
-                    oneusr->setPasswordexpiration(sb.str());
+                    oneusr->setPasswordexpiration(getPasswordExpiration(usr, sb));
                 }
                 espusers.append(*oneusr.getLink());
             }
@@ -488,6 +472,27 @@ bool Cws_accessEx::onUsers(IEspContext &context, IEspUserRequest &req, IEspUserR
     return true;
 }
 
+const char *Cws_accessEx::getPasswordExpiration(ISecUser *usr, StringBuffer &passwordExpiration)
+{
+    switch (usr->getPasswordDaysRemaining())//-1 if expired, -2 if never expires
+    {
+    case scPasswordExpired:
+        passwordExpiration.set("Expired");
+        break;
+    case scPasswordNeverExpires:
+        passwordExpiration.set("Never");
+        break;
+    default:
+        {
+            CDateTime dt;
+            usr->getPasswordExpiration(dt);
+            dt.getDateString(passwordExpiration);
+            break;
+        }
+    }
+    return passwordExpiration.str();
+}
+
 bool Cws_accessEx::onUserQuery(IEspContext &context, IEspUserQueryRequest &req, IEspUserQueryResponse &resp)
 {
     try
@@ -3714,9 +3719,15 @@ bool Cws_accessEx::onUserInfoEditInput(IEspContext &context, IEspUserInfoEditInp
 
         resp.setFirstname(user->getFirstName());
         resp.setLastname(user->getLastName());
-        if (context.getClientVersion() >= 1.10)
+        double version = context.getClientVersion();
+        if (version >= 1.10)
         {
             resp.setEmployeeID(user->getEmployeeID());
+            if (version >= 1.12)
+            {
+                StringBuffer sb;
+                resp.setPasswordExpiration(getPasswordExpiration(user, sb));
+            }
         }
     }
     catch(IException* e)

+ 1 - 0
esp/services/ws_access/ws_accessService.hpp

@@ -82,6 +82,7 @@ class Cws_accessEx : public Cws_access
     int enableDisableScopeScans(IEspContext &context, bool doEnable, StringBuffer &retMsg);
     CLdapSecManager* queryLDAPSecurityManager(IEspContext &context);
     void addResourcePermission(const char *name, int type, int allows, int denies, IArrayOf<IEspResourcePermission> &permissions);
+    const char* getPasswordExpiration(ISecUser *usr, StringBuffer &passwordExpiration);
 
 public:
     IMPLEMENT_IINTERFACE;