00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "includes.h"
00022
00023 #undef DBGC_CLASS
00024 #define DBGC_CLASS DBGC_IDMAP
00025
00026
00027
00028
00029
00030
00031 NTSTATUS idmap_uid_to_sid(DOM_SID *sid, uid_t uid)
00032 {
00033 NTSTATUS ret;
00034 struct id_map map;
00035 struct id_map *maps[2];
00036
00037 DEBUG(10,("uid = [%lu]\n", (unsigned long)uid));
00038
00039 map.sid = sid;
00040 map.xid.type = ID_TYPE_UID;
00041 map.xid.id = uid;
00042
00043 maps[0] = ↦
00044 maps[1] = NULL;
00045
00046 ret = idmap_unixids_to_sids(maps);
00047 if ( ! NT_STATUS_IS_OK(ret)) {
00048 DEBUG(10, ("error mapping uid [%lu]\n", (unsigned long)uid));
00049 return ret;
00050 }
00051
00052 if (map.status != ID_MAPPED) {
00053 DEBUG(10, ("uid [%lu] not mapped\n", (unsigned long)uid));
00054 return NT_STATUS_NONE_MAPPED;
00055 }
00056
00057 return NT_STATUS_OK;
00058 }
00059
00060
00061
00062
00063
00064
00065 NTSTATUS idmap_gid_to_sid(DOM_SID *sid, gid_t gid)
00066 {
00067 NTSTATUS ret;
00068 struct id_map map;
00069 struct id_map *maps[2];
00070
00071 DEBUG(10,("gid = [%lu]\n", (unsigned long)gid));
00072
00073 map.sid = sid;
00074 map.xid.type = ID_TYPE_GID;
00075 map.xid.id = gid;
00076
00077 maps[0] = ↦
00078 maps[1] = NULL;
00079
00080 ret = idmap_unixids_to_sids(maps);
00081 if ( ! NT_STATUS_IS_OK(ret)) {
00082 DEBUG(10, ("error mapping gid [%lu]\n", (unsigned long)gid));
00083 return ret;
00084 }
00085
00086 if (map.status != ID_MAPPED) {
00087 DEBUG(10, ("gid [%lu] not mapped\n", (unsigned long)gid));
00088 return NT_STATUS_NONE_MAPPED;
00089 }
00090
00091 return NT_STATUS_OK;
00092 }
00093
00094
00095
00096
00097
00098
00099 NTSTATUS idmap_sid_to_uid(DOM_SID *sid, uid_t *uid)
00100 {
00101 NTSTATUS ret;
00102 struct id_map map;
00103 struct id_map *maps[2];
00104
00105 DEBUG(10,("idmap_sid_to_uid: sid = [%s]\n", sid_string_static(sid)));
00106
00107 map.sid = sid;
00108 map.xid.type = ID_TYPE_UID;
00109
00110 maps[0] = ↦
00111 maps[1] = NULL;
00112
00113 ret = idmap_sids_to_unixids(maps);
00114 if ( ! NT_STATUS_IS_OK(ret)) {
00115 DEBUG(10, ("error mapping sid [%s] to uid\n",
00116 sid_string_static(sid)));
00117 return ret;
00118 }
00119
00120 if ((map.status != ID_MAPPED) || (map.xid.type != ID_TYPE_UID)) {
00121 DEBUG(10, ("sid [%s] not mapped to an uid [%u,%u,%u]\n",
00122 sid_string_static(sid),
00123 map.status,
00124 map.xid.type,
00125 map.xid.id));
00126 return NT_STATUS_NONE_MAPPED;
00127 }
00128
00129 *uid = map.xid.id;
00130
00131 return NT_STATUS_OK;
00132 }
00133
00134
00135
00136
00137
00138
00139 NTSTATUS idmap_sid_to_gid(DOM_SID *sid, gid_t *gid)
00140 {
00141 NTSTATUS ret;
00142 struct id_map map;
00143 struct id_map *maps[2];
00144
00145 DEBUG(10,("idmap_sid_to_gid: sid = [%s]\n", sid_string_static(sid)));
00146
00147 map.sid = sid;
00148 map.xid.type = ID_TYPE_GID;
00149
00150 maps[0] = ↦
00151 maps[1] = NULL;
00152
00153 ret = idmap_sids_to_unixids(maps);
00154 if ( ! NT_STATUS_IS_OK(ret)) {
00155 DEBUG(10, ("error mapping sid [%s] to gid\n",
00156 sid_string_static(sid)));
00157 return ret;
00158 }
00159
00160 if ((map.status != ID_MAPPED) || (map.xid.type != ID_TYPE_GID)) {
00161 DEBUG(10, ("sid [%s] not mapped to an gid [%u,%u]\n",
00162 sid_string_static(sid),
00163 map.status,
00164 map.xid.type));
00165 return NT_STATUS_NONE_MAPPED;
00166 }
00167
00168 *gid = map.xid.id;
00169
00170 return NT_STATUS_OK;
00171 }