summaryrefslogtreecommitdiffstats
path: root/source3/smbd/session.c
diff options
context:
space:
mode:
authorShekhar Amlekar <samlekar@in.ibm.com>2013-09-10 11:58:07 +0530
committerJeremy Allison <jra@samba.org>2013-09-10 11:32:46 -0700
commit69470a2efdf36f306292515c1ed596b576e95120 (patch)
tree506a1eb4da01532ef00a832356afea21c136346e /source3/smbd/session.c
parent340f7f125db0d08ae47620e1c90a3dcd20201487 (diff)
downloadsamba-69470a2efdf36f306292515c1ed596b576e95120.tar.gz
samba-69470a2efdf36f306292515c1ed596b576e95120.tar.xz
samba-69470a2efdf36f306292515c1ed596b576e95120.zip
s3:smbd/session: Added a routine find_sessions()
this routine builds a list of sessions from a particular remote machine or user. Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/session.c')
-rw-r--r--source3/smbd/session.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index e4d68b4dead..4ddb856930d 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -184,3 +184,31 @@ int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list)
*session_list = sesslist.sessions;
return sesslist.count;
}
+
+/********************************************************************
+find the sessions that match the given username and machine
+********************************************************************/
+
+int find_sessions(TALLOC_CTX *mem_ctx, const char *username,
+ const char *machine, struct sessionid **session_list)
+{
+ struct session_list sesslist;
+ NTSTATUS status;
+
+ sesslist.mem_ctx = mem_ctx;
+ sesslist.count = 0;
+ sesslist.filter_user = username;
+ sesslist.filter_machine = machine;
+ sesslist.sessions = NULL;
+
+ status = sessionid_traverse_read(gather_sessioninfo, (void *)&sesslist);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("Session traverse failed: %s\n", nt_errstr(status)));
+ TALLOC_FREE(sesslist.sessions);
+ *session_list = NULL;
+ return 0;
+ }
+
+ *session_list = sesslist.sessions;
+ return sesslist.count;
+}