s3:winbind: Convert WINBINDD_LOOKUPSID to the new API
[ira/wip.git] / source3 / winbindd / winbindd_sid.c
index c091cd7f53ac7c252973b5a9103522ced7ae9e82..287dfb7f6b19c37d02a80a0127e0d3f4f5bfce1c 100644 (file)
 
 /* Convert a string  */
 
-static void lookupsid_recv(void *private_data, bool success,
-                          const char *dom_name, const char *name,
-                          enum lsa_SidType type);
-
-void winbindd_lookupsid(struct winbindd_cli_state *state)
-{
-       DOM_SID sid;
-
-       /* Ensure null termination */
-       state->request->data.sid[sizeof(state->request->data.sid)-1]='\0';
-
-       DEBUG(3, ("[%5lu]: lookupsid %s\n", (unsigned long)state->pid, 
-                 state->request->data.sid));
-
-       if (!string_to_sid(&sid, state->request->data.sid)) {
-               DEBUG(5, ("%s not a SID\n", state->request->data.sid));
-               request_error(state);
-               return;
-       }
-
-       winbindd_lookupsid_async(state->mem_ctx, &sid, lookupsid_recv, state);
-}
-
-static void lookupsid_recv(void *private_data, bool success,
-                          const char *dom_name, const char *name,
-                          enum lsa_SidType type)
-{
-       struct winbindd_cli_state *state =
-               talloc_get_type_abort(private_data, struct winbindd_cli_state);
-
-       if (!success) {
-               DEBUG(5, ("lookupsid returned an error\n"));
-               request_error(state);
-               return;
-       }
-
-       fstrcpy(state->response->data.name.dom_name, dom_name);
-       fstrcpy(state->response->data.name.name, name);
-       state->response->data.name.type = type;
-       request_ok(state);
-}
-
 /**
  * Look up the SID for a qualified name.  
  **/
@@ -93,6 +51,11 @@ void winbindd_lookupname(struct winbindd_cli_state *state)
                *p = 0;
                name_domain = state->request->data.name.name;
                name_user = p+1;
+       } else if ((p = strchr(state->request->data.name.name, '@')) != NULL) {
+               /* upn */
+               name_domain = p + 1;
+               *p = 0;
+               name_user = state->request->data.name.name;
        } else {
                name_domain = state->request->data.name.dom_name;
                name_user = state->request->data.name.name;