2009-02-01 16:08:45 +01:00
/*
Unix SMB / CIFS implementation .
Samba utility functions
Copyright ( C ) Stefan ( metze ) Metzmacher 2002 - 2004
Copyright ( C ) Andrew Tridgell 1992 - 2004
Copyright ( C ) Jeremy Allison 1999
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef _DOM_SID_H_
# define _DOM_SID_H_
2021-09-16 17:04:47 +02:00
# include "replace.h"
# include <talloc.h>
# include "lib/util/data_blob.h"
2009-03-01 18:15:15 +01:00
# include "librpc/gen_ndr/security.h"
2010-09-18 12:55:31 +10:00
/* Some well-known SIDs */
extern const struct dom_sid global_sid_World_Domain ;
extern const struct dom_sid global_sid_World ;
2011-09-01 16:09:01 +02:00
extern const struct dom_sid global_sid_Local_Authority ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_Creator_Owner_Domain ;
extern const struct dom_sid global_sid_NT_Authority ;
2010-09-21 07:14:38 +10:00
extern const struct dom_sid global_sid_Enterprise_DCs ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_System ;
extern const struct dom_sid global_sid_NULL ;
2023-09-11 14:13:09 +12:00
extern const struct dom_sid global_sid_Self ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_Authenticated_Users ;
extern const struct dom_sid global_sid_Network ;
2016-01-15 14:46:07 +01:00
extern const struct dom_sid global_sid_Asserted_Identity ;
extern const struct dom_sid global_sid_Asserted_Identity_Service ;
extern const struct dom_sid global_sid_Asserted_Identity_Authentication_Authority ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_Creator_Owner ;
extern const struct dom_sid global_sid_Creator_Group ;
2012-03-13 16:47:17 -07:00
extern const struct dom_sid global_sid_Owner_Rights ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_Anonymous ;
2023-09-11 14:27:14 +12:00
extern const struct dom_sid global_sid_Compounded_Authentication ;
extern const struct dom_sid global_sid_Claims_Valid ;
2010-09-18 12:55:31 +10:00
extern const struct dom_sid global_sid_Builtin ;
extern const struct dom_sid global_sid_Builtin_Administrators ;
extern const struct dom_sid global_sid_Builtin_Users ;
extern const struct dom_sid global_sid_Builtin_Guests ;
extern const struct dom_sid global_sid_Builtin_Power_Users ;
extern const struct dom_sid global_sid_Builtin_Account_Operators ;
extern const struct dom_sid global_sid_Builtin_Server_Operators ;
extern const struct dom_sid global_sid_Builtin_Print_Operators ;
extern const struct dom_sid global_sid_Builtin_Backup_Operators ;
extern const struct dom_sid global_sid_Builtin_Replicator ;
extern const struct dom_sid global_sid_Builtin_PreWin2kAccess ;
extern const struct dom_sid global_sid_Unix_Users ;
extern const struct dom_sid global_sid_Unix_Groups ;
2014-09-08 23:18:35 +02:00
extern const struct dom_sid global_sid_Unix_NFS ;
extern const struct dom_sid global_sid_Unix_NFS_Users ;
extern const struct dom_sid global_sid_Unix_NFS_Groups ;
extern const struct dom_sid global_sid_Unix_NFS_Mode ;
extern const struct dom_sid global_sid_Unix_NFS_Other ;
2021-10-08 11:34:23 +02:00
extern const struct dom_sid global_sid_Samba_SMB3 ;
2010-09-18 12:55:31 +10:00
2023-04-18 12:09:45 +02:00
extern const struct dom_sid global_sid_Samba_NPA_Flags ;
# define SAMBA_NPA_FLAGS_NEED_IDLE 1
2023-04-18 12:47:04 +02:00
# define SAMBA_NPA_FLAGS_WINBIND_OFF 2
2023-04-18 12:09:45 +02:00
2022-09-27 15:12:52 +13:00
struct auth_SidAttr ;
2017-03-20 12:55:44 +01:00
enum lsa_SidType ;
NTSTATUS dom_sid_lookup_predefined_name ( const char * name ,
const struct dom_sid * * sid ,
enum lsa_SidType * type ,
const struct dom_sid * * authority_sid ,
const char * * authority_name ) ;
NTSTATUS dom_sid_lookup_predefined_sid ( const struct dom_sid * sid ,
const char * * name ,
enum lsa_SidType * type ,
const struct dom_sid * * authority_sid ,
const char * * authority_name ) ;
2018-11-28 17:19:39 +01:00
bool dom_sid_lookup_is_predefined_domain ( const char * domain ) ;
2017-03-20 12:55:44 +01:00
2010-09-18 12:55:31 +10:00
int dom_sid_compare_auth ( const struct dom_sid * sid1 ,
const struct dom_sid * sid2 ) ;
2009-02-01 16:08:45 +01:00
int dom_sid_compare ( const struct dom_sid * sid1 , const struct dom_sid * sid2 ) ;
2010-08-26 16:41:15 +02:00
int dom_sid_compare_domain ( const struct dom_sid * sid1 ,
const struct dom_sid * sid2 ) ;
2009-02-01 16:08:45 +01:00
bool dom_sid_equal ( const struct dom_sid * sid1 , const struct dom_sid * sid2 ) ;
2010-09-18 12:55:31 +10:00
bool sid_append_rid ( struct dom_sid * sid , uint32_t rid ) ;
bool string_to_sid ( struct dom_sid * sidout , const char * sidstr ) ;
2011-03-07 20:16:13 +01:00
bool dom_sid_parse_endp ( const char * sidstr , struct dom_sid * sidout ,
const char * * endp ) ;
2009-02-01 16:08:45 +01:00
bool dom_sid_parse ( const char * sidstr , struct dom_sid * ret ) ;
struct dom_sid * dom_sid_parse_talloc ( TALLOC_CTX * mem_ctx , const char * sidstr ) ;
struct dom_sid * dom_sid_parse_length ( TALLOC_CTX * mem_ctx , const DATA_BLOB * sid ) ;
struct dom_sid * dom_sid_dup ( TALLOC_CTX * mem_ctx , const struct dom_sid * dom_sid ) ;
struct dom_sid * dom_sid_add_rid ( TALLOC_CTX * mem_ctx ,
const struct dom_sid * domain_sid ,
uint32_t rid ) ;
NTSTATUS dom_sid_split_rid ( TALLOC_CTX * mem_ctx , const struct dom_sid * sid ,
struct dom_sid * * domain , uint32_t * rid ) ;
bool dom_sid_in_domain ( const struct dom_sid * domain_sid ,
const struct dom_sid * sid ) ;
2023-03-16 11:25:57 +13:00
bool dom_sid_has_account_domain ( const struct dom_sid * sid ) ;
2018-01-25 09:50:17 +01:00
bool dom_sid_is_valid_account_domain ( const struct dom_sid * sid ) ;
2011-03-03 16:59:39 +01:00
# define DOM_SID_STR_BUFLEN (15*11+25)
2009-02-01 16:08:45 +01:00
char * dom_sid_string ( TALLOC_CTX * mem_ctx , const struct dom_sid * sid ) ;
2018-10-18 05:46:37 +02:00
struct dom_sid_buf { char buf [ DOM_SID_STR_BUFLEN ] ; } ;
char * dom_sid_str_buf ( const struct dom_sid * sid , struct dom_sid_buf * dst ) ;
2010-09-18 12:55:31 +10:00
const char * sid_type_lookup ( uint32_t sid_type ) ;
const struct security_token * get_system_token ( void ) ;
bool sid_compose ( struct dom_sid * dst , const struct dom_sid * domain_sid , uint32_t rid ) ;
bool sid_split_rid ( struct dom_sid * sid , uint32_t * rid ) ;
bool sid_peek_rid ( const struct dom_sid * sid , uint32_t * rid ) ;
bool sid_peek_check_rid ( const struct dom_sid * exp_dom_sid , const struct dom_sid * sid , uint32_t * rid ) ;
void sid_copy ( struct dom_sid * dst , const struct dom_sid * src ) ;
2019-03-11 17:11:06 +01:00
ssize_t sid_parse ( const uint8_t * inbuf , size_t len , struct dom_sid * sid ) ;
2010-09-18 12:55:31 +10:00
NTSTATUS add_sid_to_array ( TALLOC_CTX * mem_ctx , const struct dom_sid * sid ,
struct dom_sid * * sids , uint32_t * num ) ;
NTSTATUS add_sid_to_array_unique ( TALLOC_CTX * mem_ctx , const struct dom_sid * sid ,
struct dom_sid * * sids , uint32_t * num_sids ) ;
2022-09-27 15:12:52 +13:00
NTSTATUS add_sid_to_array_attrs ( TALLOC_CTX * mem_ctx ,
const struct dom_sid * sid , uint32_t attrs ,
struct auth_SidAttr * * sids , uint32_t * num ) ;
NTSTATUS add_sid_to_array_attrs_unique ( TALLOC_CTX * mem_ctx ,
const struct dom_sid * sid , uint32_t attrs ,
struct auth_SidAttr * * sids , uint32_t * num_sids ) ;
2011-02-03 05:22:36 -07:00
void del_sid_from_array ( const struct dom_sid * sid , struct dom_sid * * sids ,
uint32_t * num ) ;
2010-09-18 12:55:31 +10:00
bool add_rid_to_array_unique ( TALLOC_CTX * mem_ctx ,
uint32_t rid , uint32_t * * pp_rids , size_t * p_num ) ;
bool is_null_sid ( const struct dom_sid * sid ) ;
2023-10-30 14:51:17 +13:00
bool sids_contains_sid ( const struct dom_sid * sids ,
const uint32_t num_sids ,
const struct dom_sid * sid ) ;
2023-10-30 15:03:04 +13:00
bool sid_attrs_contains_sid ( const struct auth_SidAttr * sids ,
const uint32_t num_sids ,
const struct dom_sid * sid ) ;
2023-10-30 14:48:23 +13:00
bool sids_contains_sid_attrs ( const struct auth_SidAttr * sids ,
const uint32_t num_sids ,
const struct dom_sid * sid ,
uint32_t attrs ) ;
2010-09-18 12:55:31 +10:00
2009-02-01 16:08:45 +01:00
# endif /*_DOM_SID_H_*/