Support NSPI property lookup (NspiGetMatches) based on account name.
authorbradh <bradh@71d39326-ef09-db11-b2a4-00e04c779ad1>
Sat, 22 Jan 2011 23:36:25 +0000 (23:36 +0000)
committerbradh <bradh@71d39326-ef09-db11-b2a4-00e04c779ad1>
Sat, 22 Jan 2011 23:36:25 +0000 (23:36 +0000)
This helps with some of the tests - it appears to be a fairly common case.

git-svn-id: https://svn.openchange.org/openchange@2539 71d39326-ef09-db11-b2a4-00e04c779ad1

branches/mapistore_v2/mapiproxy/servers/default/nspi/emsabp.c

index 4c8a285cdd3e7a2833f403a9b30ebd189129fc61..d34d40174c3f16c714c0536b4053408ee4bf8ff5 100644 (file)
@@ -1032,21 +1032,32 @@ _PUBLIC_ enum MAPISTATUS emsabp_search(TALLOC_CTX *mem_ctx, struct emsabp_contex
                        return MAPI_E_TOO_COMPLEX;
                }
 
-               /* FIXME: We only support PR_ANR */
+               /* FIXME: We only support a very few query types */
                res_prop = (struct PropertyRestriction_r *)&(restriction->res.resProperty);
-               if ((res_prop->ulPropTag != PR_ANR) && (res_prop->ulPropTag != PR_ANR_UNICODE)) {
+               if ((res_prop->ulPropTag == PR_ANR) || (res_prop->ulPropTag == PR_ANR_UNICODE)) {
+                       /* Ambiguous name resolution */
+                       recipient = (res_prop->ulPropTag == PR_ANR) ?
+                               res_prop->lpProp->value.lpszA :
+                               res_prop->lpProp->value.lpszW;
+
+                       ret = ldb_search(emsabp_ctx->samdb_ctx, emsabp_ctx->mem_ctx, &res,
+                                       ldb_get_default_basedn(emsabp_ctx->samdb_ctx),
+                                       LDB_SCOPE_SUBTREE, recipient_attrs,
+                                       "(&(objectClass=user)(sAMAccountName=*%s*)(!(objectClass=computer)))",
+                                       recipient);
+               } else if ((res_prop->ulPropTag == PR_ACCOUNT) || (res_prop->ulPropTag == PR_ACCOUNT_UNICODE)) {
+                       const char *account_name = (res_prop->ulPropTag == PR_ACCOUNT) ? res_prop->lpProp->value.lpszA : res_prop->lpProp->value.lpszW;
+                       DEBUG(5, ("* [%s:%d][%s] account name: %s\n", __FILE__, __LINE__, __FUNCTION__, account_name));
+                       ret = ldb_search(emsabp_ctx->samdb_ctx, emsabp_ctx->mem_ctx, &res,
+                                        ldb_get_default_basedn(emsabp_ctx->samdb_ctx),
+                                        LDB_SCOPE_SUBTREE, recipient_attrs,
+                                        "(&(objectClass=user)(sAMAccountName=%s)(!(objectClass=computer)))",
+                                        account_name);
+               } else {
+                       /* another query type */
+                       DEBUG(0, ("! [%s:%d][%s] real lookup not supported yet\n", __FILE__, __LINE__, __FUNCTION__));
                        return MAPI_E_NO_SUPPORT;
                }
-               
-               recipient = (res_prop->ulPropTag == PR_ANR) ?
-                       res_prop->lpProp->value.lpszA :
-                       res_prop->lpProp->value.lpszW;
-
-               ret = ldb_search(emsabp_ctx->samdb_ctx, emsabp_ctx->mem_ctx, &res,
-                                ldb_get_default_basedn(emsabp_ctx->samdb_ctx),
-                                LDB_SCOPE_SUBTREE, recipient_attrs,
-                                "(&(objectClass=user)(sAMAccountName=*%s*)(!(objectClass=computer)))",
-                                recipient);
 
                if (ret != LDB_SUCCESS) {
                        return MAPI_E_NOT_FOUND;