ReactOS  0.4.15-dev-492-ga1108f6
group.c File Reference
#include "samsrv.h"
Include dependency graph for group.c:

Go to the source code of this file.

Functions

NTSTATUS SampOpenGroupObject (IN PSAM_DB_OBJECT DomainObject, IN ULONG GroupId, IN ACCESS_MASK DesiredAccess, OUT PSAM_DB_OBJECT *GroupObject)
 
NTSTATUS SampAddMemberToGroup (IN PSAM_DB_OBJECT GroupObject, IN ULONG MemberId)
 
NTSTATUS SampRemoveMemberFromGroup (IN PSAM_DB_OBJECT GroupObject, IN ULONG MemberId)
 

Function Documentation

◆ SampAddMemberToGroup()

NTSTATUS SampAddMemberToGroup ( IN PSAM_DB_OBJECT  GroupObject,
IN ULONG  MemberId 
)

Definition at line 39 of file group.c.

41 {
42  PULONG MembersBuffer = NULL;
43  ULONG MembersCount = 0;
44  ULONG Length = 0;
45  ULONG i;
47 
48  Status = SampGetObjectAttribute(GroupObject,
49  L"Members",
50  NULL,
51  NULL,
52  &Length);
54  goto done;
55 
56  MembersBuffer = midl_user_allocate(Length + sizeof(ULONG));
57  if (MembersBuffer == NULL)
58  {
60  goto done;
61  }
62 
64  {
65  Status = SampGetObjectAttribute(GroupObject,
66  L"Members",
67  NULL,
68  MembersBuffer,
69  &Length);
70  if (!NT_SUCCESS(Status))
71  goto done;
72 
73  MembersCount = Length / sizeof(ULONG);
74  }
75 
76  for (i = 0; i < MembersCount; i++)
77  {
78  if (MembersBuffer[i] == MemberId)
79  {
81  goto done;
82  }
83  }
84 
85  MembersBuffer[MembersCount] = MemberId;
86  Length += sizeof(ULONG);
87 
88  Status = SampSetObjectAttribute(GroupObject,
89  L"Members",
90  REG_BINARY,
91  MembersBuffer,
92  Length);
93 
94 done:
95  if (MembersBuffer != NULL)
96  midl_user_free(MembersBuffer);
97 
98  return Status;
99 }
#define midl_user_free
Definition: rpc.h:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define REG_BINARY
Definition: nt_native.h:1496
#define midl_user_allocate
Definition: rpc.h:44
NTSTATUS SampSetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, ULONG AttributeType, LPVOID AttributeData, ULONG AttributeSize)
Definition: database.c:499
LONG NTSTATUS
Definition: precomp.h:26
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_MEMBER_IN_GROUP
Definition: ntstatus.h:325
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS SampGetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, PULONG AttributeType, LPVOID AttributeData, PULONG AttributeSize)
Definition: database.c:514
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

Referenced by SamrAddMemberToGroup().

◆ SampOpenGroupObject()

NTSTATUS SampOpenGroupObject ( IN PSAM_DB_OBJECT  DomainObject,
IN ULONG  GroupId,
IN ACCESS_MASK  DesiredAccess,
OUT PSAM_DB_OBJECT GroupObject 
)

Definition at line 14 of file group.c.

18 {
19  WCHAR szRid[9];
20 
21  TRACE("(%p %lu %lx %p)\n",
22  DomainObject, GroupId, DesiredAccess, GroupObject);
23 
24  /* Convert the RID into a string (hex) */
25  swprintf(szRid, L"%08lX", GroupId);
26 
27  /* Create the user object */
28  return SampOpenDbObject(DomainObject,
29  L"Groups",
30  szRid,
31  GroupId,
34  GroupObject);
35 }
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4137
NTSTATUS SampOpenDbObject(IN PSAM_DB_OBJECT ParentObject, IN LPWSTR ContainerName, IN LPWSTR ObjectName, IN ULONG RelativeId, IN SAM_DB_OBJECT_TYPE ObjectType, IN ACCESS_MASK DesiredAccess, OUT PSAM_DB_OBJECT *DbObject)
Definition: database.c:171

Referenced by SampRemoveUserFromAllGroups().

◆ SampRemoveMemberFromGroup()

NTSTATUS SampRemoveMemberFromGroup ( IN PSAM_DB_OBJECT  GroupObject,
IN ULONG  MemberId 
)

Definition at line 103 of file group.c.

105 {
106  PULONG MembersBuffer = NULL;
107  ULONG MembersCount = 0;
108  ULONG Length = 0;
109  ULONG i;
111 
112  SampGetObjectAttribute(GroupObject,
113  L"Members",
114  NULL,
115  NULL,
116  &Length);
117 
118  if (Length == 0)
120 
121  MembersBuffer = midl_user_allocate(Length);
122  if (MembersBuffer == NULL)
123  {
125  goto done;
126  }
127 
128  Status = SampGetObjectAttribute(GroupObject,
129  L"Members",
130  NULL,
131  MembersBuffer,
132  &Length);
133  if (!NT_SUCCESS(Status))
134  goto done;
135 
137 
138  MembersCount = Length / sizeof(ULONG);
139  for (i = 0; i < MembersCount; i++)
140  {
141  if (MembersBuffer[i] == MemberId)
142  {
143  Length -= sizeof(ULONG);
145 
146  if (MembersCount - i - 1 > 0)
147  {
148  CopyMemory(&MembersBuffer[i],
149  &MembersBuffer[i + 1],
150  (MembersCount - i - 1) * sizeof(ULONG));
151  }
152 
153  break;
154  }
155  }
156 
157  if (!NT_SUCCESS(Status))
158  goto done;
159 
160  Status = SampSetObjectAttribute(GroupObject,
161  L"Members",
162  REG_BINARY,
163  MembersBuffer,
164  Length);
165 
166 done:
167  if (MembersBuffer != NULL)
168  midl_user_free(MembersBuffer);
169 
170  return Status;
171 }
#define STATUS_MEMBER_NOT_IN_GROUP
Definition: ntstatus.h:326
#define midl_user_free
Definition: rpc.h:45
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define REG_BINARY
Definition: nt_native.h:1496
#define midl_user_allocate
Definition: rpc.h:44
NTSTATUS SampSetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, ULONG AttributeType, LPVOID AttributeData, ULONG AttributeSize)
Definition: database.c:499
LONG NTSTATUS
Definition: precomp.h:26
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CopyMemory
Definition: winbase.h:1646
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS SampGetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, PULONG AttributeType, LPVOID AttributeData, PULONG AttributeSize)
Definition: database.c:514
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by SampRemoveUserFromAllGroups(), and SamrRemoveMemberFromGroup().