summaryrefslogtreecommitdiffstats
path: root/source/sam
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-04-05 08:53:23 +0000
committerSimo Sorce <idra@samba.org>2003-04-05 08:53:23 +0000
commit5ac94535d7b7ce0cc0d44b9a77d6e42ddfd0cd26 (patch)
tree8cb393e5bacc44cf488f8f60a548b262eaf93a35 /source/sam
parent7dac688c4d296433a62cc8665aab90ce387f6599 (diff)
downloadsamba-5ac94535d7b7ce0cc0d44b9a77d6e42ddfd0cd26.tar.gz
samba-5ac94535d7b7ce0cc0d44b9a77d6e42ddfd0cd26.tar.xz
samba-5ac94535d7b7ce0cc0d44b9a77d6e42ddfd0cd26.zip
some more idmapping :)
Diffstat (limited to 'source/sam')
-rw-r--r--source/sam/idmap_winbind.c79
1 files changed, 61 insertions, 18 deletions
diff --git a/source/sam/idmap_winbind.c b/source/sam/idmap_winbind.c
index a5ba6586749..c2c46cfb579 100644
--- a/source/sam/idmap_winbind.c
+++ b/source/sam/idmap_winbind.c
@@ -21,48 +21,91 @@
*/
#include "includes.h"
+#include "nsswitch/winbind_nss.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_IDMAP
+extern DOM_SID global_sid_NULL; /* NULL sid */
+
+NSS_STATUS winbindd_request(int req_type,
+ struct winbindd_request *request,
+ struct winbindd_response *response);
+
/* Get a sid from an id */
-static NTSTATUS db_get_sid_from_id(DOM_SID *sid, unid_t id, int id_type) {
+static NTSTATUS db_get_sid_from_id(DOM_SID *sid, unid_t id, int id_type)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ int result, operation;
+ fstring sid_str;
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
switch (id_type & ID_TYPEMASK) {
case ID_USERID:
- if (winbind_uid_to_sid(sid, id.uid)) {
- return NT_STATUS_OK;
- }
+ request.data.uid = id.uid;
+ operation = WINBINDD_UID_TO_SID;
break;
case ID_GROUPID:
- if (winbind_gid_to_sid(sid, id.gid)) {
- return NT_STATUS_OK;
- }
+ request.data.gid = id.gid;
+ operation = WINBINDD_GID_TO_SID;
break;
default:
return NT_STATUS_INVALID_PARAMETER;
}
+ /* Make The Request */
+ result = winbindd_request(operation, &request, &response);
+ if (result == NSS_STATUS_SUCCESS) {
+ if (!string_to_sid(sid, response.data.sid.sid)) {
+ return NT_STATUS_INVALID_SID;
+ }
+ return NT_STATUS_OK;
+ } else {
+ sid_copy(sid, &global_sid_NULL);
+ }
+
return NT_STATUS_UNSUCCESSFUL;
}
/* Get an id from a sid */
-static NTSTATUS db_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *sid) {
+static NTSTATUS db_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *sid)
+{
+ struct winbindd_request request;
+ struct winbindd_response response;
+ int result, operation;
+ fstring sid_str;
+
+ if (!id || !id_type) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
switch (*id_type & ID_TYPEMASK) {
case ID_USERID:
- if (winbind_sid_to_uid(&((*id).uid), sid)) {
- return NT_STATUS_OK;
- }
+ operation = WINBINDD_SID_TO_UID;
break;
case ID_GROUPID:
- if (winbind_sid_to_gid(&((*id).gid), sid)) {
- return NT_STATUS_OK;
- }
+ operation = WINBINDD_SID_TO_GID;
break;
default:
- if (winbind_sid_to_uid(&((*id).uid), sid) ||
- winbind_sid_to_gid(&((*id).gid), sid)) {
- return NT_STATUS_OK;
- }
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ /* Make The Request */
+ result = winbindd_request(operation, &request, &response);
+
+ if (result == NSS_STATUS_SUCCESS) {
+ if (operation == WINBINDD_SID_TO_UID) {
+ (*id).uid = response.data.uid;
+ } else {
+ (*id).gid = response.data.gid;
+ }
+ return NT_STATUS_OK;
}
return NT_STATUS_UNSUCCESSFUL;