From: Marten van de Sanden <m.vandesanden@xxxxxxxxxx> When calling (soap) resolveUserStore on a company name in hosted mode a warning message was incorrectly logged. This removes that warning message. --- provider/libserver/ECUserManagement.cpp | 14 +++++++++----- provider/libserver/ECUserManagement.h | 5 +++-- provider/libserver/cmd.cpp | 5 +++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/provider/libserver/ECUserManagement.cpp b/provider/libserver/ECUserManagement.cpp index 85ba58bae..cf80d3f34 100644 --- a/provider/libserver/ECUserManagement.cpp +++ b/provider/libserver/ECUserManagement.cpp @@ -873,7 +873,9 @@ ECRESULT ECUserManagement::ResolveObject(objectclass_t objclass, * Resolve an object name to an object id, with on-the-fly creation of the * specified object class. */ -ECRESULT ECUserManagement::ResolveObjectAndSync(objectclass_t objclass, const char* szName, unsigned int* lpulObjectId) { +ECRESULT ECUserManagement::ResolveObjectAndSync(objectclass_t objclass, + const char* szName, unsigned int* lpulObjectId, bool tryResolve) +{ objectsignature_t objectsignature; std::string username, companyname; UserPlugin *lpPlugin = NULL; @@ -949,12 +951,14 @@ ECRESULT ECUserManagement::ResolveObjectAndSync(objectclass_t objclass, const ch } catch (const notsupported &) { return KCERR_NO_SUPPORT; } catch (const objectnotfound &e) { - ec_log_warn("K-1515: Object not found %s \"%s\": %s", - ObjectClassToName(objclass), szName, e.what()); + if (!tryResolve) + ec_log_warn("K-1515: Object not found %s \"%s\": %s", + ObjectClassToName(objclass), szName, e.what()); return KCERR_NOT_FOUND; } catch (const std::exception &e) { - ec_log_warn("K-1516: Unable to resolve %s \"%s\": %s", - ObjectClassToName(objclass), szName, e.what()); + if (!tryResolve) + ec_log_warn("K-1516: Unable to resolve %s \"%s\": %s", + ObjectClassToName(objclass), szName, e.what()); return KCERR_NOT_FOUND; } return GetLocalObjectIdOrCreate(objectsignature, lpulObjectId); diff --git a/provider/libserver/ECUserManagement.h b/provider/libserver/ECUserManagement.h index e53572a7a..2535d3be2 100644 --- a/provider/libserver/ECUserManagement.h +++ b/provider/libserver/ECUserManagement.h @@ -67,8 +67,9 @@ public: /* Add a member to a group, with on-the-fly deletion of the specified group id. */ _kc_hidden virtual ECRESULT AddSubObjectToObjectAndSync(userobject_relation_t, unsigned int parent_id, unsigned int child_id); _kc_hidden virtual ECRESULT DeleteSubObjectFromObjectAndSync(userobject_relation_t, unsigned int parent_id, unsigned int child_id); - /* Resolve a user name to a user id, with on-the-fly creation of the specified user. */ - _kc_hidden virtual ECRESULT ResolveObjectAndSync(objectclass_t, const char *name, unsigned int *obj_id); + /* Resolve a user name to a user id, with on-the-fly creation of the + specified user. When 'tryResolve' is set surpress logging warnings */ + _kc_hidden virtual ECRESULT ResolveObjectAndSync(objectclass_t, const char *name, unsigned int *obj_id, bool tryResolve = false); // Get a local object ID for a part of a name virtual ECRESULT SearchObjectAndSync(const char *search_string, unsigned int flags, unsigned int *id); diff --git a/provider/libserver/cmd.cpp b/provider/libserver/cmd.cpp index 3c366efcc..0193030d6 100644 --- a/provider/libserver/cmd.cpp +++ b/provider/libserver/cmd.cpp @@ -5919,8 +5919,9 @@ SOAP_ENTRY_START(resolveUserStore, lpsResponse->er, const char *szUserName, ulStoreTypeMask = ECSTORE_TYPE_MASK_PRIVATE | ECSTORE_TYPE_MASK_PUBLIC; auto usrmgt = lpecSession->GetUserManagement(); - er = usrmgt->ResolveObjectAndSync(OBJECTCLASS_USER, szUserName, &ulObjectId); - if ((er == KCERR_NOT_FOUND || er == KCERR_INVALID_PARAMETER) && lpecSession->GetSessionManager()->IsHostedSupported()) + bool hosted = lpecSession->GetSessionManager()->IsHostedSupported(); + er = usrmgt->ResolveObjectAndSync(OBJECTCLASS_USER, szUserName, &ulObjectId, hosted); + if ((er == KCERR_NOT_FOUND || er == KCERR_INVALID_PARAMETER) && hosted) // FIXME: this function is being misused, szUserName can also be a company name er = usrmgt->ResolveObjectAndSync(CONTAINER_COMPANY, szUserName, &ulObjectId); if (er != erSuccess) -- 2.21.0