~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to srvsvc/client/net_sharegetinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Editor Settings: expandtabs and use 4 spaces for indentation
2
 
 * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
3
 
 */
4
 
 
5
 
/*
6
 
 * Copyright Likewise Software    2004-2008
7
 
 * All rights reserved.
8
 
 *
9
 
 * This library is free software; you can redistribute it and/or modify it
10
 
 * under the terms of the GNU Lesser General Public License as published by
11
 
 * the Free Software Foundation; either version 2.1 of the license, or (at
12
 
 * your option) any later version.
13
 
 *
14
 
 * This library is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
17
 
 * General Public License for more details.  You should have received a copy
18
 
 * of the GNU Lesser General Public License along with this program.  If
19
 
 * not, see <http://www.gnu.org/licenses/>.
20
 
 *
21
 
 * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
22
 
 * TERMS AS WELL.  IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
23
 
 * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
24
 
 * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
25
 
 * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE.  IF YOU
26
 
 * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
27
 
 * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
28
 
 * license@likewisesoftware.com
29
 
 */
30
 
 
31
 
#include "includes.h"
32
 
 
33
 
 
34
 
NET_API_STATUS
35
 
NetShareGetInfo(
36
 
    IN  PCWSTR  pwszServername,
37
 
    IN  PCWSTR  pwszNetname,
38
 
    IN  DWORD   dwLevel,
39
 
    OUT PVOID  *ppBuffer
40
 
    )
41
 
{
42
 
    NET_API_STATUS err = ERROR_SUCCESS;
43
 
    NTSTATUS ntStatus = STATUS_SUCCESS;
44
 
    RPCSTATUS rpcStatus = RPC_S_OK;
45
 
    handle_t hBinding = NULL;
46
 
    PSTR pszServername = NULL;
47
 
    PIO_CREDS pCreds = NULL;
48
 
    PWSTR pwszServer = NULL;
49
 
    PWSTR pwszShare = NULL;
50
 
    PVOID pBuffer = NULL;
51
 
 
52
 
    BAIL_ON_INVALID_PTR(pwszNetname, err);
53
 
    BAIL_ON_INVALID_PTR(ppBuffer, err);
54
 
 
55
 
    if (pwszServername)
56
 
    {
57
 
        err = LwWc16sToMbs(pwszServername, &pszServername);
58
 
        BAIL_ON_WIN_ERROR(err);
59
 
 
60
 
        err = LwAllocateWc16String(&pwszServer, pwszServername);
61
 
        BAIL_ON_WIN_ERROR(err);
62
 
 
63
 
    }
64
 
 
65
 
    err = LwAllocateWc16String(&pwszShare, pwszNetname);
66
 
    BAIL_ON_WIN_ERROR(err);
67
 
 
68
 
    ntStatus = LwIoGetActiveCreds(NULL, &pCreds);
69
 
    BAIL_ON_NT_STATUS(ntStatus);
70
 
 
71
 
    rpcStatus = InitSrvSvcBindingDefault(&hBinding,
72
 
                                         pszServername,
73
 
                                         pCreds);
74
 
    if (rpcStatus)
75
 
    {
76
 
        ntStatus = LwRpcStatusToNtStatus(rpcStatus);
77
 
        BAIL_ON_NT_STATUS(ntStatus);
78
 
    }
79
 
 
80
 
    err = NetrShareGetInfo(hBinding,
81
 
                           pwszServer,
82
 
                           pwszShare,
83
 
                           dwLevel,
84
 
                           &pBuffer);
85
 
    BAIL_ON_WIN_ERROR(err);
86
 
 
87
 
    *ppBuffer = pBuffer;
88
 
 
89
 
cleanup:
90
 
    if (hBinding)
91
 
    {
92
 
        FreeSrvSvcBinding(&hBinding);
93
 
    }
94
 
 
95
 
    LW_SAFE_FREE_MEMORY(pszServername);
96
 
    LW_SAFE_FREE_MEMORY(pwszServer);
97
 
    LW_SAFE_FREE_MEMORY(pwszShare);
98
 
 
99
 
    if (err == ERROR_SUCCESS &&
100
 
        ntStatus != STATUS_SUCCESS)
101
 
    {
102
 
        err = LwNtStatusToWin32Error(ntStatus);
103
 
    }
104
 
 
105
 
    return err;
106
 
 
107
 
error:
108
 
    *ppBuffer = NULL;
109
 
 
110
 
    goto cleanup;
111
 
}
112
 
 
113
 
 
114
 
/*
115
 
local variables:
116
 
mode: c
117
 
c-basic-offset: 4
118
 
indent-tabs-mode: nil
119
 
tab-width: 4
120
 
end:
121
 
*/