diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/proto.h | 2 | ||||
-rw-r--r-- | source3/smbd/session.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 8b6987ec05..54d6da0b4c 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1001,6 +1001,8 @@ bool session_init(void); bool session_claim(struct smbXsrv_session *session); void session_yield(struct smbXsrv_session *session); int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list); +int find_sessions(TALLOC_CTX *mem_ctx, const char *username, + const char *machine, struct sessionid **session_list); /* The following definitions come from smbd/sesssetup.c */ diff --git a/source3/smbd/session.c b/source3/smbd/session.c index e4d68b4dea..4ddb856930 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; +} |