REPOST: libsmbclient API for verifying username/password?

David Wuertele dave-gnus at
Thu Sep 23 22:26:30 GMT 2004

Posted this before, got no reply.  Anyone have suggestions?

When my application does the following, it gets a list of all shares
on a server, even if my app uses the wrong username/password for
accessing those shares:

  cli_full_connection (&cli, NULL, server_name, &server_ip, 0, 
                       "IPC$", "IPC", username, workgroup, password, 
                        Undefined, NULL);
  mem_ctx = talloc_init ("run_rpc_command")
  cli_nt_session_open (cli, PI_LSARPC)
  cli_lsa_open_policy (cli, mem_ctx, False, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
  cli_lsa_query_info_policy (cli, mem_ctx, &pol, info_class, &domain_name, &domain_sid);
  cli_lsa_close (cli, mem_ctx, &pol);
  cli_nt_session_close (cli);
  cli_nt_session_open(cli, PI_SRVSVC)
  init_enum_hnd (&hnd, 0);
  result = cli_srvsvc_net_share_enum (cli, mem_ctx, 1, &ctr, preferred_len, &hnd);
  for (i = 0; i < ctr.num_entries; i++) {
        rpcstr_pull_unistr2_fstring (netname, &info1->info_1_str.uni_netname);
        rpcstr_pull_unistr2_fstring (remark, &info1->info_1_str.uni_remark);

Is there a way with libsmbclient, and preferably with the data I've
already initialized above, to discover whether a given username and
password is authorized to mount any of these shares?

I would rather not have to actually test-mount every share, if there
is an easier and faster RPC API.  It would be great if there is just a
field in the info structure that tells me.


More information about the samba-technical mailing list