SAM Functions


データ構造

struct  SamConnect
struct  SamOpenDomain
struct  SamCreateUser
struct  SamOpenUser
struct  SamEnumUsers
struct  SamGetNamesFromRids
struct  SamGetRidsFromNames
struct  SamGetGroupsForUser
struct  SamOpenGroup
struct  SamCreateGroup
struct  SamGetGroupMembers
struct  SamAddGroupMember
struct  SamRemoveGroupMember
struct  SamSetGroupMembers
struct  SamEnumGroups
struct  SamEnumAliases
struct  SamCreateAlias
struct  SamOpenAlias
struct  SamAddAliasMember
struct  SamRemoveAliasMember
struct  SamGetAliasMembers
struct  SamSetAliasMembers
struct  SamUserChangePasswd
struct  SamSetPassword
struct  SamGetUserInfo
struct  SamSetUserInfo
struct  SamGetUserInfoCtr
struct  SamSetUserInfoCtr
struct  SamRenameUser
struct  SamGetGroupInfo
struct  SamSetGroupInfo
struct  SamRenameGroup
struct  SamGetAliasInfo
struct  SamSetAliasInfo
struct  SamGetDomainInfo
struct  SamGetDomainInfoCtr
struct  SamGetDisplayInfo
struct  SamLookupDomain
struct  SamGetSecurityObject
struct  SamFlush

関数

int cac_SamConnect (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect *op)
 Connects to the SAM.
int cac_SamClose (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam)
 Closes any (SAM, domain, user, group, etc.
int cac_SamOpenDomain (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenDomain *op)
 Opens a handle to a domain.
int cac_SamCreateUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateUser *op)
 Creates a new domain user, if the account already exists it will _not_ be opened and hnd->status will be NT_STATUS_USER_EXISTS
int cac_SamOpenUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUser *op)
 Opens a domain user.
int cac_SamDeleteUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd)
 Deletes a domain user.
int cac_SamEnumUsers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUsers *op)
 Enumerates domain users.
int cac_SamGetNamesFromRids (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetNamesFromRids *op)
 Returns a list of names which map to a list of RIDs.
int cac_SamGetRidsFromNames (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetRidsFromNames *op)
 Returns a list of RIDs which map to a list of names.
int cac_SamGetGroupsForUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupsForUser *op)
 Retrieves a list of groups that a user is a member of.
int cac_SamOpenGroup (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGroup *op)
 Opens a domain group.
int cac_SamCreateGroup (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateGroup *op)
 Creates a group.
int cac_SamDeleteGroup (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd)
 Deletes a domain group.
int cac_SamGetGroupMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupMembers *op)
 Retrives a list of users in a group.
int cac_SamAddGroupMember (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddGroupMember *op)
 Adds a user to a group.
int cac_SamRemoveGroupMember (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveGroupMember *op)
 Removes a user from a group.
int cac_SamClearGroupMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd)
 Removes all the members of a group - warning: if this function fails is is possible that some but not all members were removed
int cac_SamSetGroupMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupMembers *op)
 Clears the members of a group and adds a list of members to the group
int cac_SamEnumGroups (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumGroups *op)
 Enumerates domain groups.
int cac_SamEnumAliases (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op)
 Enumerates domain aliases.
int cac_SamCreateAlias (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op)
 Creates an alias.
int cac_SamOpenAlias (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op)
 Opens a handle to an alias.
int cac_SamDeleteAlias (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd)
 Deletes an alias.
int cac_SamAddAliasMember (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op)
 Adds an account to an alias.
int cac_SamRemoveAliasMember (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveAliasMember *op)
 Removes an account from an alias.
int cac_SamGetAliasMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasMembers *op)
 Retrieves a list of all accounts in an alias.
int cac_SamClearAliasMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd)
 Removes all the members of an alias - warning: if this function fails is is possible that some but not all members were removed
int cac_SamSetAliasMembers (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasMembers *op)
 Clears the members of an alias and adds a list of members to the alias
int cac_SamUserChangePasswd (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamUserChangePasswd *op)
 Used by a user to change their password
int cac_SamEnableUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd)
 Enables a user
int cac_SamDisableUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd)
 Disables a user
int cac_SamSetPassword (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetPassword *op)
 Sets a user's password
int cac_SamGetUserInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfo *op)
 Retrieves user information using a CacUserInfo structure.
int cac_SamSetUserInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfo *op)
 Sets the user info using a CacUserInfo structure.
int cac_SamGetUserInfoCtr (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfoCtr *op)
 Retrieves user information using a SAM_USERINFO_CTR structure.
int cac_SamSetUserInfoCtr (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfoCtr *op)
 Sets the user info using a SAM_USERINFO_CTR structure.
int cac_SamRenameUser (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameUser *op)
 Changes the name of a user.
int cac_SamGetGroupInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupInfo *op)
 Retrieves information about a group.
int cac_SamSetGroupInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupInfo *op)
 Sets information about a group.
int cac_SamRenameGroup (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameGroup *op)
 Changes the name of a group
int cac_SamGetAliasInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasInfo *op)
 Retrieves information about an alias.
int cac_SamSetAliasInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasInfo *op)
 Sets information about an alias.
int cac_SamGetDomainInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfo *op)
 Gets domain information in the form of a CacDomainInfo structure.
int cac_SamGetDomainInfoCtr (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfoCtr *op)
 Gets domain information in the form of a SAM_UNK_CTR structure.
int cac_SamGetDisplayInfo (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDisplayInfo *op)
 Gets dislpay information using a SAM_DISPINFO_CTR.
int cac_SamLookupDomain (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLookupDomain *op)
 Looks up a Domain SID given it's name.
int cac_SamGetSecurityObject (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetSecurityObject *op)
 Retrievies Security descriptor information for a SAM/Domain/user
int cac_SamFlush (CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op)
 Closes the domain handle, then re-opens it - effectively flushing any changes made.

関数

int cac_SamConnect ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamConnect op 
)

Connects to the SAM.

This can be skipped by just calling cac_SamOpenDomain()

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c36 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamConnect::accesscac_GetPipe()cac_GetServer()_SMBCSRV::clicli_rpc_pipe_open_noauth()CacServerHandleInternal::ctxSamConnect::inSamConnect::outCacServerHandleInternal::pipesrpccli_samr_connect()rpccli_samr_connect4()SamConnect::samCacServerHandleInternal::srv_level_CACSERVERHANDLE::status.

参照元 cac_SamOpenDomain().

00038 {
00039         SMBCSRV *srv = NULL;
00040         struct rpc_pipe_client *pipe_hnd = NULL;
00041         POLICY_HND *sam_out = NULL;
00042 
00043         if ( !hnd )
00044                 return CAC_FAILURE;
00045 
00046         if ( !hnd->_internal.ctx ) {
00047                 hnd->status = NT_STATUS_INVALID_HANDLE;
00048                 return CAC_FAILURE;
00049         }
00050 
00051         if ( !op || op->in.access == 0 || !mem_ctx ) {
00052                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00053                 return CAC_FAILURE;
00054         }
00055 
00056         srv = cac_GetServer( hnd );
00057         if ( !srv ) {
00058                 hnd->status = NT_STATUS_INVALID_CONNECTION;
00059                 return CAC_FAILURE;
00060         }
00061 
00062         /*initialize for samr pipe if we have to */
00063         if ( !hnd->_internal.pipes[PI_SAMR] ) {
00064                 if ( !
00065                      ( pipe_hnd =
00066                        cli_rpc_pipe_open_noauth( srv->cli, PI_SAMR,
00067                                                  &hnd->status ) ) ) {
00068                         return CAC_FAILURE;
00069                 }
00070 
00071                 hnd->_internal.pipes[PI_SAMR] = True;
00072         }
00073 
00074         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00075         if ( !pipe_hnd ) {
00076                 hnd->status = NT_STATUS_INVALID_HANDLE;
00077                 return CAC_FAILURE;
00078         }
00079 
00080         sam_out = talloc( mem_ctx, POLICY_HND );
00081         if ( !sam_out ) {
00082                 hnd->status = NT_STATUS_NO_MEMORY;
00083                 return CAC_FAILURE;
00084         }
00085 
00086         if ( hnd->_internal.srv_level >= SRV_WIN_2K_SP3 ) {
00087                 hnd->status =
00088                         rpccli_samr_connect4( pipe_hnd, mem_ctx,
00089                                               op->in.access, sam_out );
00090         }
00091 
00092         if ( hnd->_internal.srv_level < SRV_WIN_2K_SP3
00093              || !NT_STATUS_IS_OK( hnd->status ) ) {
00094                 /*if sam_connect4 failed, the use sam_connect and lower srv_level */
00095 
00096                 hnd->status =
00097                         rpccli_samr_connect( pipe_hnd, mem_ctx, op->in.access,
00098                                              sam_out );
00099 
00100                 if ( NT_STATUS_IS_OK( hnd->status )
00101                      && hnd->_internal.srv_level > SRV_WIN_2K ) {
00102                         hnd->_internal.srv_level = SRV_WIN_2K;
00103                 }
00104         }
00105 
00106         if ( !NT_STATUS_IS_OK( hnd->status ) )
00107                 return CAC_FAILURE;
00108 
00109         op->out.sam = sam_out;
00110 
00111         return CAC_SUCCESS;
00112 }

int cac_SamClose ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND sam 
)

Closes any (SAM, domain, user, group, etc.

) SAM handle.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
sam Handle to close
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c114 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesrpccli_samr_close()_CACSERVERHANDLE::status.

参照元 cac_SamFlush().

00116 {
00117         struct rpc_pipe_client *pipe_hnd = NULL;
00118 
00119         if ( !hnd )
00120                 return CAC_FAILURE;
00121 
00122         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00123                 hnd->status = NT_STATUS_INVALID_HANDLE;
00124                 return CAC_FAILURE;
00125         }
00126 
00127         if ( !sam || !mem_ctx ) {
00128                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00129                 return CAC_FAILURE;
00130         }
00131 
00132         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00133         if ( !pipe_hnd ) {
00134                 hnd->status = NT_STATUS_INVALID_HANDLE;
00135                 return CAC_FAILURE;
00136         }
00137 
00138         hnd->status = rpccli_samr_close( pipe_hnd, mem_ctx, sam );
00139 
00140         if ( !NT_STATUS_IS_OK( hnd->status ) )
00141                 return CAC_FAILURE;
00142 
00143         return CAC_SUCCESS;
00144 }

int cac_SamOpenDomain ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamOpenDomain op 
)

Opens a handle to a domain.

This must be called before any other SAM functions

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c191 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamOpenDomain::accesscac_get_domain_sid()cac_GetPipe()cac_SamConnect()cac_SamLookupDomain()CacServerHandleInternal::ctxSamOpenDomain::dom_hnd_CACSERVERHANDLE::domainSamOpenDomain::inSamLookupDomain::inSamLookupDomain::nameSamLookupDomain::outSamOpenDomain::outrpccli_samr_open_domain()SamOpenDomain::samSamLookupDomain::samscSamOpenDomain::sidSamLookupDomain::sid_CACSERVERHANDLE::status.

参照元 cac_SamFlush().

00193 {
00194         struct rpc_pipe_client *pipe_hnd = NULL;
00195 
00196         DOM_SID *sid_buf;
00197         POLICY_HND *sam_out;
00198         POLICY_HND *pol_out;
00199 
00200         struct SamLookupDomain sld;
00201 
00202         if ( !hnd )
00203                 return CAC_FAILURE;
00204 
00205         if ( !hnd->_internal.ctx ) {
00206                 hnd->status = NT_STATUS_INVALID_HANDLE;
00207                 return CAC_FAILURE;
00208         }
00209 
00210         if ( !op || op->in.access == 0 || !mem_ctx ) {
00211                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00212                 return CAC_FAILURE;
00213         }
00214 
00215         if ( !op->in.sam ) {
00216                 /*use cac_SamConnect() since it does the session setup */
00217                 struct SamConnect sc;
00218 
00219                 ZERO_STRUCT( sc );
00220 
00221                 sc.in.access = op->in.access;
00222 
00223                 if ( !cac_SamConnect( hnd, mem_ctx, &sc ) ) {
00224                         return CAC_FAILURE;
00225                 }
00226 
00227                 sam_out = sc.out.sam;
00228         } else {
00229                 sam_out = op->in.sam;
00230         }
00231 
00232         if ( !op->in.sid ) {
00233                 /*find the sid for the SAM's domain */
00234 
00235                 /*try using cac_SamLookupDomain() first */
00236                 ZERO_STRUCT( sld );
00237 
00238                 sld.in.sam = sam_out;
00239                 sld.in.name = hnd->domain;
00240 
00241                 if ( cac_SamLookupDomain( hnd, mem_ctx, &sld ) ) {
00242                         /*then we got the sid */
00243                         sid_buf = sld.out.sid;
00244                 } else {
00245                         /*try to get it from the LSA */
00246                         sid_buf =
00247                                 cac_get_domain_sid( hnd, mem_ctx,
00248                                                     op->in.access );
00249                 }
00250         } else {
00251                 /*we already have the sid for the domain we want */
00252                 sid_buf = op->in.sid;
00253         }
00254 
00255         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00256         if ( !pipe_hnd ) {
00257                 hnd->status = NT_STATUS_INVALID_HANDLE;
00258                 return CAC_FAILURE;
00259         }
00260 
00261         pol_out = talloc( mem_ctx, POLICY_HND );
00262         if ( !pol_out ) {
00263                 hnd->status = NT_STATUS_NO_MEMORY;
00264                 return CAC_FAILURE;
00265         }
00266 
00267         /*now open the domain */
00268         hnd->status =
00269                 rpccli_samr_open_domain( pipe_hnd, mem_ctx, sam_out,
00270                                          op->in.access, sid_buf, pol_out );
00271 
00272         if ( !NT_STATUS_IS_OK( hnd->status ) )
00273                 return CAC_FAILURE;
00274 
00275         op->out.sam = sam_out;
00276         op->out.dom_hnd = pol_out;
00277 
00278         return CAC_SUCCESS;
00279 }

int cac_SamCreateUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamCreateUser op 
)

Creates a new domain user, if the account already exists it will _not_ be opened and hnd->status will be NT_STATUS_USER_EXISTS

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c361 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamCreateUser::acb_maskcac_GetPipe()CacServerHandleInternal::ctxSamCreateUser::dom_hndSamCreateUser::inSamCreateUser::nameSamCreateUser::outCacServerHandleInternal::pipesSamCreateUser::ridrpccli_samr_create_dom_user()_CACSERVERHANDLE::statusSamCreateUser::user_hnd.

00363 {
00364         struct rpc_pipe_client *pipe_hnd = NULL;
00365 
00366         POLICY_HND *user_out = NULL;
00367         uint32 rid_out;
00368         uint32 acct_flags=0;
00369 
00370         if ( !hnd )
00371                 return CAC_FAILURE;
00372 
00373         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00374                 hnd->status = NT_STATUS_INVALID_HANDLE;
00375                 return CAC_FAILURE;
00376         }
00377 
00378         if ( !op || !op->in.dom_hnd || !op->in.name || op->in.acb_mask == 0
00379              || !mem_ctx ) {
00380                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00381                 return CAC_FAILURE;
00382         }
00383 
00384         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00385         if ( !pipe_hnd ) {
00386                 hnd->status = NT_STATUS_INVALID_HANDLE;
00387                 return CAC_FAILURE;
00388         }
00389 
00390         user_out = talloc( mem_ctx, POLICY_HND );
00391         if ( !user_out ) {
00392                 hnd->status = NT_STATUS_NO_MEMORY;
00393                 return CAC_FAILURE;
00394         }
00395 
00396         acct_flags = SAMR_GENERIC_READ | SAMR_GENERIC_WRITE |
00397                 SAMR_GENERIC_EXECUTE | SAMR_STANDARD_WRITEDAC |
00398                 SAMR_STANDARD_DELETE | SAMR_USER_SETPASS | SAMR_USER_GETATTR |
00399                 SAMR_USER_SETATTR;
00400         DEBUG(10, ("Creating account with flags: %d\n",acct_flags));
00401 
00402         hnd->status =
00403                 rpccli_samr_create_dom_user( pipe_hnd, mem_ctx,
00404                                              op->in.dom_hnd, op->in.name,
00405                                              op->in.acb_mask, acct_flags,
00406                                              user_out, &rid_out );
00407 
00408         if ( !NT_STATUS_IS_OK( hnd->status ) )
00409                 return CAC_FAILURE;
00410 
00411         op->out.user_hnd = user_out;
00412         op->out.rid = rid_out;
00413 
00414         return CAC_SUCCESS;
00415 }

int cac_SamOpenUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamOpenUser op 
)

Opens a domain user.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c281 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamOpenUser::accesscac_GetPipe()CacServerHandleInternal::ctxSamOpenUser::dom_hndSamOpenUser::inSamOpenUser::namenameSamOpenUser::outCacServerHandleInternal::pipesSamOpenUser::ridrpccli_samr_lookup_names()rpccli_samr_open_user()_CACSERVERHANDLE::statusSamOpenUser::user_hnd.

00283 {
00284         struct rpc_pipe_client *pipe_hnd = NULL;
00285 
00286         uint32 *rid_buf = NULL;
00287 
00288         uint32 num_rids = 0;
00289         uint32 *rid_types = NULL;
00290 
00291         POLICY_HND *user_out = NULL;
00292 
00293         if ( !hnd )
00294                 return CAC_FAILURE;
00295 
00296         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00297                 hnd->status = NT_STATUS_INVALID_HANDLE;
00298                 return CAC_FAILURE;
00299         }
00300 
00301         if ( !op || !op->in.dom_hnd || op->in.access == 0 || !mem_ctx ) {
00302                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00303                 return CAC_FAILURE;
00304         }
00305 
00306         if ( op->in.rid == 0 && op->in.name == NULL ) {
00307                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00308                 return CAC_FAILURE;
00309         }
00310 
00311         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00312         if ( !pipe_hnd ) {
00313                 hnd->status = NT_STATUS_INVALID_HANDLE;
00314                 return CAC_FAILURE;
00315         }
00316 
00317         if ( op->in.rid == 0 && op->in.name ) {
00318                 /*lookup the name and then set rid_buf */
00319 
00320                 hnd->status =
00321                         rpccli_samr_lookup_names( pipe_hnd, mem_ctx,
00322                                                   op->in.dom_hnd,
00323                                                   SAMR_LOOKUP_FLAGS, 1,
00324                                                   ( const char ** ) &op->in.
00325                                                   name, &num_rids, &rid_buf,
00326                                                   &rid_types );
00327 
00328                 if ( !NT_STATUS_IS_OK( hnd->status ) )
00329                         return CAC_FAILURE;
00330 
00331                 if ( num_rids == 0 || rid_buf == NULL
00332                      || rid_types[0] == SAMR_RID_UNKNOWN ) {
00333                         hnd->status = NT_STATUS_INVALID_PARAMETER;
00334                         return CAC_FAILURE;
00335                 }
00336 
00337                 TALLOC_FREE( rid_types );
00338 
00339         } else {
00340                 rid_buf = &op->in.rid;
00341         }
00342 
00343         user_out = talloc( mem_ctx, POLICY_HND );
00344         if ( !user_out ) {
00345                 hnd->status = NT_STATUS_NO_MEMORY;
00346                 return CAC_FAILURE;
00347         }
00348 
00349         hnd->status =
00350                 rpccli_samr_open_user( pipe_hnd, mem_ctx, op->in.dom_hnd,
00351                                        op->in.access, *rid_buf, user_out );
00352 
00353         if ( !NT_STATUS_IS_OK( hnd->status ) )
00354                 return CAC_FAILURE;
00355 
00356         op->out.user_hnd = user_out;
00357 
00358         return CAC_SUCCESS;
00359 }

int cac_SamDeleteUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND user_hnd 
)

Deletes a domain user.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
user_hnd Open handle to the user
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c417 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesrpccli_samr_delete_dom_user()_CACSERVERHANDLE::status.

00419 {
00420         struct rpc_pipe_client *pipe_hnd = NULL;
00421 
00422         if ( !hnd )
00423                 return CAC_FAILURE;
00424 
00425         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00426                 hnd->status = NT_STATUS_INVALID_HANDLE;
00427                 return CAC_FAILURE;
00428         }
00429 
00430         if ( !user_hnd || !mem_ctx ) {
00431                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00432                 return CAC_FAILURE;
00433         }
00434 
00435         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00436         if ( !pipe_hnd ) {
00437                 hnd->status = NT_STATUS_INVALID_HANDLE;
00438                 return CAC_FAILURE;
00439         }
00440 
00441         hnd->status =
00442                 rpccli_samr_delete_dom_user( pipe_hnd, mem_ctx, user_hnd );
00443 
00444         if ( !NT_STATUS_IS_OK( hnd->status ) )
00445                 return CAC_FAILURE;
00446 
00447         return CAC_SUCCESS;
00448 }

int cac_SamEnumUsers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamEnumUsers op 
)

Enumerates domain users.

Can be used as a loop condition. Example: while(cac_SamEnumUsers(hnd, mem_ctx, op)) { ... }

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c450 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamEnumUsers::acb_maskcac_GetPipe()CacServerHandleInternal::ctxSamEnumUsers::dom_hndSamEnumUsers::doneSamEnumUsers::inSamEnumUsers::namesSamEnumUsers::num_usersSamEnumUsers::outCacServerHandleInternal::pipesSamEnumUsers::resume_idxSamEnumUsers::ridsrpccli_samr_enum_dom_users()_CACSERVERHANDLE::status.

00452 {
00453         struct rpc_pipe_client *pipe_hnd = NULL;
00454 
00455         uint32 resume_idx_out = 0;
00456         char **names_out = NULL;
00457         uint32 *rids_out = NULL;
00458         uint32 num_users_out = 0;
00459 
00460         if ( !hnd )
00461                 return CAC_FAILURE;
00462 
00463         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00464                 hnd->status = NT_STATUS_INVALID_HANDLE;
00465                 return CAC_FAILURE;
00466         }
00467 
00468         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
00469                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00470                 return CAC_FAILURE;
00471         }
00472 
00473         /*this is a hack.. but is the only reliable way to know if everything has been enumerated */
00474         if ( op->out.done == True )
00475                 return CAC_FAILURE;
00476 
00477         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00478         if ( !pipe_hnd ) {
00479                 hnd->status = NT_STATUS_INVALID_HANDLE;
00480                 return CAC_FAILURE;
00481         }
00482 
00483         resume_idx_out = op->out.resume_idx;
00484 
00485         hnd->status =
00486                 rpccli_samr_enum_dom_users( pipe_hnd, mem_ctx, op->in.dom_hnd,
00487                                             &resume_idx_out, op->in.acb_mask,
00488                                             SAMR_ENUM_MAX_SIZE, &names_out,
00489                                             &rids_out, &num_users_out );
00490 
00491 
00492         if ( NT_STATUS_IS_OK( hnd->status ) )
00493                 op->out.done = True;
00494 
00495         /*if there are no more entries, the operation will return NT_STATUS_OK. 
00496          * We want to return failure if no results were returned*/
00497         if ( !NT_STATUS_IS_OK( hnd->status )
00498              && NT_STATUS_V( hnd->status ) !=
00499              NT_STATUS_V( STATUS_MORE_ENTRIES ) )
00500                 return CAC_FAILURE;
00501 
00502         op->out.resume_idx = resume_idx_out;
00503         op->out.num_users = num_users_out;
00504         op->out.rids = rids_out;
00505         op->out.names = names_out;
00506 
00507         return CAC_SUCCESS;
00508 }

int cac_SamGetNamesFromRids ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetNamesFromRids op 
)

Returns a list of names which map to a list of RIDs.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c510 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamGetNamesFromRids::dom_hnd_CACLOOKUPRIDSRECORD::foundSamGetNamesFromRids::inSamGetNamesFromRids::map_CACLOOKUPRIDSRECORD::nameSamGetNamesFromRids::num_namesSamGetNamesFromRids::num_ridsSamGetNamesFromRids::outCacServerHandleInternal::pipes_CACLOOKUPRIDSRECORD::ridSamGetNamesFromRids::ridsrpccli_samr_lookup_rids()_CACSERVERHANDLE::statustalloc_strdup()_CACLOOKUPRIDSRECORD::type.

00512 {
00513         struct rpc_pipe_client *pipe_hnd = NULL;
00514 
00515         uint32 num_names_out;
00516         char **names_out;
00517         uint32 *name_types_out;
00518 
00519 
00520         uint32 i = 0;
00521 
00522         CacLookupRidsRecord *map_out;
00523 
00524         if ( !hnd )
00525                 return CAC_FAILURE;
00526 
00527         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00528                 hnd->status = NT_STATUS_INVALID_HANDLE;
00529                 return CAC_FAILURE;
00530         }
00531 
00532         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
00533                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00534                 return CAC_FAILURE;
00535         }
00536 
00537         if ( !op->in.rids && op->in.num_rids != 0 ) {
00538                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00539                 return CAC_FAILURE;
00540         }
00541 
00542         if ( op->in.num_rids == 0 ) {
00543                 /*nothing to do */
00544                 op->out.num_names = 0;
00545                 return CAC_SUCCESS;
00546         }
00547 
00548         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00549         if ( !pipe_hnd ) {
00550                 hnd->status = NT_STATUS_INVALID_HANDLE;
00551                 return CAC_FAILURE;
00552         }
00553 
00554         hnd->status =
00555                 rpccli_samr_lookup_rids( pipe_hnd, mem_ctx, op->in.dom_hnd,
00556                                          op->in.num_rids, op->in.rids,
00557                                          &num_names_out, &names_out,
00558                                          &name_types_out );
00559 
00560         if ( !NT_STATUS_IS_OK( hnd->status )
00561              && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
00562                 return CAC_FAILURE;
00563 
00564         if (num_names_out) {
00565                 map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_names_out );
00566                 if ( !map_out ) {
00567                         hnd->status = NT_STATUS_NO_MEMORY;
00568                         return CAC_FAILURE;
00569                 }
00570         } else {
00571                 map_out = NULL;
00572         }
00573 
00574         for ( i = 0; i < num_names_out; i++ ) {
00575                 if ( name_types_out[i] == SAMR_RID_UNKNOWN ) {
00576                         map_out[i].found = False;
00577                         map_out[i].name = NULL;
00578                         map_out[i].type = 0;
00579                 } else {
00580                         map_out[i].found = True;
00581                         map_out[i].name =
00582                                 talloc_strdup( mem_ctx, names_out[i] );
00583                         map_out[i].type = name_types_out[i];
00584                 }
00585                 map_out[i].rid = op->in.rids[i];
00586         }
00587 
00588         TALLOC_FREE( names_out );
00589         TALLOC_FREE( name_types_out );
00590 
00591         op->out.num_names = num_names_out;
00592         op->out.map = map_out;
00593 
00594         if ( NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
00595                 return CAC_PARTIAL_SUCCESS;
00596 
00597         return CAC_SUCCESS;
00598 }

int cac_SamGetRidsFromNames ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetRidsFromNames op 
)

Returns a list of RIDs which map to a list of names.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c600 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamGetRidsFromNames::dom_hnd_CACLOOKUPRIDSRECORD::foundSamGetRidsFromNames::inSamGetRidsFromNames::map_CACLOOKUPRIDSRECORD::nameSamGetRidsFromNames::namesSamGetRidsFromNames::num_namesSamGetRidsFromNames::num_ridsSamGetRidsFromNames::outCacServerHandleInternal::pipes_CACLOOKUPRIDSRECORD::ridrpccli_samr_lookup_names()_CACSERVERHANDLE::statustalloc_strdup()_CACLOOKUPRIDSRECORD::type.

00602 {
00603         struct rpc_pipe_client *pipe_hnd = NULL;
00604 
00605         uint32 num_rids_out;
00606         uint32 *rids_out;
00607         uint32 *rid_types_out;
00608 
00609         uint32 i = 0;
00610 
00611         CacLookupRidsRecord *map_out;
00612 
00613         if ( !hnd )
00614                 return CAC_FAILURE;
00615 
00616         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00617                 hnd->status = NT_STATUS_INVALID_HANDLE;
00618                 return CAC_FAILURE;
00619         }
00620 
00621         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
00622                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00623                 return CAC_FAILURE;
00624         }
00625 
00626         if ( !op->in.names && op->in.num_names != 0 ) {
00627                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00628                 return CAC_FAILURE;
00629         }
00630 
00631         if ( op->in.num_names == 0 ) {
00632                 /*then we don't have to do anything */
00633                 op->out.num_rids = 0;
00634                 return CAC_SUCCESS;
00635         }
00636 
00637         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00638         if ( !pipe_hnd ) {
00639                 hnd->status = NT_STATUS_INVALID_HANDLE;
00640                 return CAC_FAILURE;
00641         }
00642 
00643         hnd->status =
00644                 rpccli_samr_lookup_names( pipe_hnd, mem_ctx, op->in.dom_hnd,
00645                                           SAMR_LOOKUP_FLAGS, op->in.num_names,
00646                                           ( const char ** ) op->in.names,
00647                                           &num_rids_out, &rids_out,
00648                                           &rid_types_out );
00649 
00650         if ( !NT_STATUS_IS_OK( hnd->status )
00651              && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
00652                 return CAC_FAILURE;
00653 
00654         if (num_rids_out) {
00655                 map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_rids_out );
00656                 if ( !map_out ) {
00657                         hnd->status = NT_STATUS_NO_MEMORY;
00658                         return CAC_FAILURE;
00659                 }
00660         } else {
00661                 map_out = NULL;
00662         }
00663 
00664         for ( i = 0; i < num_rids_out; i++ ) {
00665 
00666                 if ( rid_types_out[i] == SAMR_RID_UNKNOWN ) {
00667                         map_out[i].found = False;
00668                         map_out[i].rid = 0;
00669                         map_out[i].type = 0;
00670                 } else {
00671                         map_out[i].found = True;
00672                         map_out[i].rid = rids_out[i];
00673                         map_out[i].type = rid_types_out[i];
00674                 }
00675 
00676                 map_out[i].name = talloc_strdup( mem_ctx, op->in.names[i] );
00677         }
00678 
00679         op->out.num_rids = num_rids_out;
00680         op->out.map = map_out;
00681 
00682         TALLOC_FREE( rids_out );
00683         TALLOC_FREE( rid_types_out );
00684 
00685         if ( NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) )
00686                 return CAC_PARTIAL_SUCCESS;
00687 
00688         return CAC_SUCCESS;
00689 }

int cac_SamGetGroupsForUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetGroupsForUser op 
)

Retrieves a list of groups that a user is a member of.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c692 行で定義されています。

参照先 _CACSERVERHANDLE::_internalDOM_GID::attrSamGetGroupsForUser::attributescac_GetPipe()CacServerHandleInternal::ctxSamGetGroupsForUser::inSamGetGroupsForUser::num_groupsSamGetGroupsForUser::outCacServerHandleInternal::pipesSamGetGroupsForUser::ridsrpccli_samr_query_usergroups()_CACSERVERHANDLE::statusSamGetGroupsForUser::user_hnd.

00694 {
00695         struct rpc_pipe_client *pipe_hnd = NULL;
00696 
00697         DOM_GID *groups = NULL;
00698         uint32 num_groups_out = 0;
00699 
00700         uint32 *rids_out = NULL;
00701         uint32 *attr_out = NULL;
00702 
00703         uint32 i;
00704 
00705         if ( !hnd )
00706                 return CAC_FAILURE;
00707 
00708         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00709                 hnd->status = NT_STATUS_INVALID_HANDLE;
00710                 return CAC_FAILURE;
00711         }
00712 
00713         if ( !op || !op->in.user_hnd || !mem_ctx ) {
00714                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00715                 return CAC_FAILURE;
00716         }
00717 
00718         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00719         if ( !pipe_hnd ) {
00720                 hnd->status = NT_STATUS_INVALID_HANDLE;
00721                 return CAC_FAILURE;
00722         }
00723 
00724         hnd->status =
00725                 rpccli_samr_query_usergroups( pipe_hnd, mem_ctx,
00726                                               op->in.user_hnd,
00727                                               &num_groups_out, &groups );
00728 
00729         if ( !NT_STATUS_IS_OK( hnd->status ) )
00730                 return CAC_FAILURE;
00731 
00732 
00733         if (num_groups_out) {
00734                 rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
00735                 if ( !rids_out ) {
00736                         hnd->status = NT_STATUS_NO_MEMORY;
00737                         return CAC_FAILURE;
00738                 }
00739                 attr_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
00740                 if ( !attr_out ) {
00741                         hnd->status = NT_STATUS_NO_MEMORY;
00742                         return CAC_FAILURE;
00743                 }
00744         } else {
00745                 rids_out = NULL;
00746                 attr_out = NULL;
00747         }
00748 
00749         for ( i = 0; i < num_groups_out; i++ ) {
00750                 rids_out[i] = groups[i].g_rid;
00751                 attr_out[i] = groups[i].attr;
00752         }
00753 
00754         TALLOC_FREE( groups );
00755 
00756         op->out.num_groups = num_groups_out;
00757         op->out.rids = rids_out;
00758         op->out.attributes = attr_out;
00759 
00760         return CAC_SUCCESS;
00761 }

int cac_SamOpenGroup ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamOpenGroup op 
)

Opens a domain group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c764 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamOpenGroup::accesscac_GetPipe()CacServerHandleInternal::ctxSamOpenGroup::dom_hndSamOpenGroup::group_hndSamOpenGroup::inSamOpenGroup::outCacServerHandleInternal::pipesSamOpenGroup::ridrpccli_samr_open_group()_CACSERVERHANDLE::status.

00766 {
00767         struct rpc_pipe_client *pipe_hnd = NULL;
00768 
00769         POLICY_HND *group_hnd_out = NULL;
00770 
00771         if ( !hnd )
00772                 return CAC_FAILURE;
00773 
00774         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00775                 hnd->status = NT_STATUS_INVALID_HANDLE;
00776                 return CAC_FAILURE;
00777         }
00778 
00779         if ( !op || op->in.access == 0 || op->in.rid == 0 || !mem_ctx ) {
00780                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00781                 return CAC_FAILURE;
00782         }
00783 
00784         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00785         if ( !pipe_hnd ) {
00786                 hnd->status = NT_STATUS_INVALID_HANDLE;
00787                 return CAC_FAILURE;
00788         }
00789 
00790         group_hnd_out = talloc( mem_ctx, POLICY_HND );
00791         if ( !group_hnd_out ) {
00792                 hnd->status = NT_STATUS_NO_MEMORY;
00793                 return CAC_FAILURE;
00794         }
00795 
00796         hnd->status =
00797                 rpccli_samr_open_group( pipe_hnd, mem_ctx, op->in.dom_hnd,
00798                                         op->in.access, op->in.rid,
00799                                         group_hnd_out );
00800 
00801         if ( !NT_STATUS_IS_OK( hnd->status ) )
00802                 return CAC_FAILURE;
00803 
00804         op->out.group_hnd = group_hnd_out;
00805 
00806         return CAC_SUCCESS;
00807 }

int cac_SamCreateGroup ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamCreateGroup op 
)

Creates a group.

If the group already exists it will not be opened.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c809 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamCreateGroup::accesscac_GetPipe()CacServerHandleInternal::ctxSamCreateGroup::dom_hndSamCreateGroup::group_hndSamCreateGroup::inSamCreateGroup::nameSamCreateGroup::outCacServerHandleInternal::pipesrpccli_samr_create_dom_group()_CACSERVERHANDLE::status.

00811 {
00812         struct rpc_pipe_client *pipe_hnd = NULL;
00813 
00814         POLICY_HND *group_hnd_out = NULL;
00815 
00816         if ( !hnd )
00817                 return CAC_FAILURE;
00818 
00819         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00820                 hnd->status = NT_STATUS_INVALID_HANDLE;
00821                 return CAC_FAILURE;
00822         }
00823 
00824         if ( !op || !op->in.name || op->in.name[0] == '\0'
00825              || op->in.access == 0 || !mem_ctx ) {
00826                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00827                 return CAC_FAILURE;
00828         }
00829 
00830         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00831         if ( !pipe_hnd ) {
00832                 hnd->status = NT_STATUS_INVALID_HANDLE;
00833                 return CAC_FAILURE;
00834         }
00835 
00836         group_hnd_out = talloc( mem_ctx, POLICY_HND );
00837         if ( !group_hnd_out ) {
00838                 hnd->status = NT_STATUS_NO_MEMORY;
00839                 return CAC_FAILURE;
00840         }
00841 
00842         hnd->status =
00843                 rpccli_samr_create_dom_group( pipe_hnd, mem_ctx,
00844                                               op->in.dom_hnd, op->in.name,
00845                                               op->in.access, group_hnd_out );
00846 
00847         if ( !NT_STATUS_IS_OK( hnd->status ) )
00848                 return CAC_FAILURE;
00849 
00850         op->out.group_hnd = group_hnd_out;
00851 
00852         return CAC_SUCCESS;
00853 
00854 }

int cac_SamDeleteGroup ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND group_hnd 
)

Deletes a domain group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
group_hnd Open handle to the group.
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c856 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesrpccli_samr_delete_dom_group()_CACSERVERHANDLE::status.

00858 {
00859         struct rpc_pipe_client *pipe_hnd = NULL;
00860 
00861         if ( !hnd )
00862                 return CAC_FAILURE;
00863 
00864         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00865                 hnd->status = NT_STATUS_INVALID_HANDLE;
00866                 return CAC_FAILURE;
00867         }
00868 
00869         if ( !group_hnd || !mem_ctx ) {
00870                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00871                 return CAC_FAILURE;
00872         }
00873 
00874         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00875         if ( !pipe_hnd ) {
00876                 hnd->status = NT_STATUS_INVALID_HANDLE;
00877                 return CAC_FAILURE;
00878         }
00879 
00880         hnd->status =
00881                 rpccli_samr_delete_dom_group( pipe_hnd, mem_ctx, group_hnd );
00882 
00883         if ( !NT_STATUS_IS_OK( hnd->status ) )
00884                 return CAC_FAILURE;
00885 
00886         return CAC_SUCCESS;
00887 
00888 }

int cac_SamGetGroupMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetGroupMembers op 
)

Retrives a list of users in a group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c890 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamGetGroupMembers::attributescac_GetPipe()CacServerHandleInternal::ctxSamGetGroupMembers::group_hndSamGetGroupMembers::inSamGetGroupMembers::num_membersSamGetGroupMembers::outCacServerHandleInternal::pipesSamGetGroupMembers::ridsrpccli_samr_query_groupmem()_CACSERVERHANDLE::status.

00892 {
00893         struct rpc_pipe_client *pipe_hnd = NULL;
00894 
00895         uint32 num_mem_out;
00896         uint32 *rids_out;
00897         uint32 *attr_out;
00898 
00899         if ( !hnd )
00900                 return CAC_FAILURE;
00901 
00902         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00903                 hnd->status = NT_STATUS_INVALID_HANDLE;
00904                 return CAC_FAILURE;
00905         }
00906 
00907         if ( !op || !op->in.group_hnd || !mem_ctx ) {
00908                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00909                 return CAC_FAILURE;
00910         }
00911 
00912         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00913         if ( !pipe_hnd ) {
00914                 hnd->status = NT_STATUS_INVALID_HANDLE;
00915                 return CAC_FAILURE;
00916         }
00917 
00918         hnd->status =
00919                 rpccli_samr_query_groupmem( pipe_hnd, mem_ctx,
00920                                             op->in.group_hnd, &num_mem_out,
00921                                             &rids_out, &attr_out );
00922 
00923         if ( !NT_STATUS_IS_OK( hnd->status ) )
00924                 return CAC_FAILURE;
00925 
00926         op->out.num_members = num_mem_out;
00927         op->out.rids = rids_out;
00928         op->out.attributes = attr_out;
00929 
00930         return CAC_SUCCESS;
00931 }

int cac_SamAddGroupMember ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamAddGroupMember op 
)

Adds a user to a group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c934 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamAddGroupMember::group_hndSamAddGroupMember::inCacServerHandleInternal::pipesSamAddGroupMember::ridrpccli_samr_add_groupmem()_CACSERVERHANDLE::status.

00936 {
00937         struct rpc_pipe_client *pipe_hnd = NULL;
00938 
00939         if ( !hnd )
00940                 return CAC_FAILURE;
00941 
00942         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00943                 hnd->status = NT_STATUS_INVALID_HANDLE;
00944                 return CAC_FAILURE;
00945         }
00946 
00947         if ( !op || !op->in.group_hnd || op->in.rid == 0 || !mem_ctx ) {
00948                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00949                 return CAC_FAILURE;
00950         }
00951 
00952         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00953         if ( !pipe_hnd ) {
00954                 hnd->status = NT_STATUS_INVALID_HANDLE;
00955                 return CAC_FAILURE;
00956         }
00957 
00958         hnd->status =
00959                 rpccli_samr_add_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd,
00960                                           op->in.rid );
00961 
00962         if ( !NT_STATUS_IS_OK( hnd->status ) )
00963                 return CAC_FAILURE;
00964 
00965         return CAC_SUCCESS;
00966 }

int cac_SamRemoveGroupMember ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamRemoveGroupMember op 
)

Removes a user from a group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c968 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamRemoveGroupMember::group_hndSamRemoveGroupMember::inCacServerHandleInternal::pipesSamRemoveGroupMember::ridrpccli_samr_del_groupmem()_CACSERVERHANDLE::status.

00970 {
00971         struct rpc_pipe_client *pipe_hnd = NULL;
00972 
00973         if ( !hnd )
00974                 return CAC_FAILURE;
00975 
00976         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
00977                 hnd->status = NT_STATUS_INVALID_HANDLE;
00978                 return CAC_FAILURE;
00979         }
00980 
00981         if ( !op || !op->in.group_hnd || op->in.rid == 0 || !mem_ctx ) {
00982                 hnd->status = NT_STATUS_INVALID_PARAMETER;
00983                 return CAC_FAILURE;
00984         }
00985 
00986         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
00987         if ( !pipe_hnd ) {
00988                 hnd->status = NT_STATUS_INVALID_HANDLE;
00989                 return CAC_FAILURE;
00990         }
00991 
00992         hnd->status =
00993                 rpccli_samr_del_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd,
00994                                           op->in.rid );
00995 
00996         if ( !NT_STATUS_IS_OK( hnd->status ) )
00997                 return CAC_FAILURE;
00998 
00999         return CAC_SUCCESS;
01000 }

int cac_SamClearGroupMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND group_hnd 
)

Removes all the members of a group - warning: if this function fails is is possible that some but not all members were removed

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
group_hnd Open handle to the group to clear
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1002 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesresultrpccli_samr_add_groupmem()rpccli_samr_del_groupmem()rpccli_samr_query_groupmem()status_CACSERVERHANDLE::status.

参照元 cac_SamSetGroupMembers().

01004 {
01005         struct rpc_pipe_client *pipe_hnd = NULL;
01006 
01007         int result = CAC_SUCCESS;
01008 
01009         int i = 0;
01010 
01011         uint32 num_mem = 0;
01012         uint32 *rid = NULL;
01013         uint32 *attr = NULL;
01014 
01015         NTSTATUS status;
01016 
01017         if ( !hnd )
01018                 return CAC_FAILURE;
01019 
01020         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01021                 hnd->status = NT_STATUS_INVALID_HANDLE;
01022                 return CAC_FAILURE;
01023         }
01024 
01025         if ( !group_hnd || !mem_ctx ) {
01026                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01027                 return CAC_FAILURE;
01028         }
01029 
01030         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01031         if ( !pipe_hnd ) {
01032                 hnd->status = NT_STATUS_INVALID_HANDLE;
01033                 return CAC_FAILURE;
01034         }
01035 
01036         hnd->status =
01037                 rpccli_samr_query_groupmem( pipe_hnd, mem_ctx, group_hnd,
01038                                             &num_mem, &rid, &attr );
01039 
01040         if ( !NT_STATUS_IS_OK( hnd->status ) )
01041                 return CAC_FAILURE;
01042 
01043         /*try to delete the users one by one */
01044         for ( i = 0; i < num_mem && NT_STATUS_IS_OK( hnd->status ); i++ ) {
01045                 hnd->status =
01046                         rpccli_samr_del_groupmem( pipe_hnd, mem_ctx,
01047                                                   group_hnd, rid[i] );
01048         }
01049 
01050         /*if not all members could be removed, then try to re-add the members that were already deleted */
01051         if ( !NT_STATUS_IS_OK( hnd->status ) ) {
01052                 status = NT_STATUS_OK;
01053 
01054                 for ( i -= 1; i >= 0 && NT_STATUS_IS_OK( status ); i-- ) {
01055                         status = rpccli_samr_add_groupmem( pipe_hnd, mem_ctx,
01056                                                            group_hnd,
01057                                                            rid[i] );
01058                 }
01059 
01060                 /*we return with the NTSTATUS error that we got when trying to delete users */
01061                 if ( !NT_STATUS_IS_OK( status ) )
01062                         result = CAC_FAILURE;
01063         }
01064 
01065         TALLOC_FREE( attr );
01066 
01067         return result;
01068 }

int cac_SamSetGroupMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetGroupMembers op 
)

Clears the members of a group and adds a list of members to the group

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1070 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_SamClearGroupMembers()CacServerHandleInternal::ctxSamSetGroupMembers::group_hndSamSetGroupMembers::inSamSetGroupMembers::num_membersCacServerHandleInternal::pipesSamSetGroupMembers::ridsrpccli_samr_add_groupmem()_CACSERVERHANDLE::status.

01072 {
01073         struct rpc_pipe_client *pipe_hnd = NULL;
01074 
01075         uint32 i = 0;
01076 
01077         if ( !hnd )
01078                 return CAC_FAILURE;
01079 
01080         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01081                 hnd->status = NT_STATUS_INVALID_HANDLE;
01082                 return CAC_FAILURE;
01083         }
01084 
01085         if ( !op || !op->in.group_hnd || !mem_ctx ) {
01086                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01087                 return CAC_FAILURE;
01088         }
01089 
01090         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01091         if ( !pipe_hnd ) {
01092                 hnd->status = NT_STATUS_INVALID_HANDLE;
01093                 return CAC_FAILURE;
01094         }
01095 
01096         /*use cac_SamClearGroupMembers() to clear them */
01097         if ( !cac_SamClearGroupMembers( hnd, mem_ctx, op->in.group_hnd ) )
01098                 return CAC_FAILURE;     /*hnd->status is already set */
01099 
01100 
01101         for ( i = 0; i < op->in.num_members && NT_STATUS_IS_OK( hnd->status );
01102               i++ ) {
01103                 hnd->status =
01104                         rpccli_samr_add_groupmem( pipe_hnd, mem_ctx,
01105                                                   op->in.group_hnd,
01106                                                   op->in.rids[i] );
01107         }
01108 
01109         if ( !NT_STATUS_IS_OK( hnd->status ) )
01110                 return CAC_FAILURE;
01111 
01112         return CAC_SUCCESS;
01113 
01114 }

int cac_SamEnumGroups ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamEnumGroups op 
)

Enumerates domain groups.

Can be used as a loop condition. Example: while(cac_SamEnumGroups(hnd, mem_ctx, op)) { ... }

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1116 行で定義されています。

参照先 _CACSERVERHANDLE::_internalacct_info::acct_descacct_info::acct_namecac_GetPipe()CacServerHandleInternal::ctxSamEnumGroups::descriptionsSamEnumGroups::dom_hndSamEnumGroups::doneSamEnumGroups::inSamEnumGroups::namesSamEnumGroups::num_groupsSamEnumGroups::outCacServerHandleInternal::pipesSamEnumGroups::resume_idxacct_info::ridSamEnumGroups::ridsrpccli_samr_enum_dom_groups()_CACSERVERHANDLE::statustalloc_strdup().

01118 {
01119         struct rpc_pipe_client *pipe_hnd = NULL;
01120 
01121         uint32 i = 0;
01122 
01123         uint32 resume_idx_out = 0;
01124         char **names_out = NULL;
01125         char **desc_out = NULL;
01126         uint32 *rids_out = NULL;
01127         uint32 num_groups_out = 0;
01128 
01129         struct acct_info *acct_buf = NULL;
01130 
01131         if ( !hnd )
01132                 return CAC_FAILURE;
01133 
01134         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01135                 hnd->status = NT_STATUS_INVALID_HANDLE;
01136                 return CAC_FAILURE;
01137         }
01138 
01139         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
01140                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01141                 return CAC_FAILURE;
01142         }
01143 
01144         /*using this BOOL is the only reliable way to know that we are done */
01145         if ( op->out.done == True )     /*we return failure so the call will break out of a loop */
01146                 return CAC_FAILURE;
01147 
01148         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01149         if ( !pipe_hnd ) {
01150                 hnd->status = NT_STATUS_INVALID_HANDLE;
01151                 return CAC_FAILURE;
01152         }
01153 
01154         resume_idx_out = op->out.resume_idx;
01155 
01156         hnd->status =
01157                 rpccli_samr_enum_dom_groups( pipe_hnd, mem_ctx,
01158                                              op->in.dom_hnd, &resume_idx_out,
01159                                              SAMR_ENUM_MAX_SIZE, &acct_buf,
01160                                              &num_groups_out );
01161 
01162 
01163         if ( NT_STATUS_IS_OK( hnd->status ) ) {
01164                 op->out.done = True;
01165         } else if ( NT_STATUS_V( hnd->status ) !=
01166                     NT_STATUS_V( STATUS_MORE_ENTRIES ) ) {
01167                 /*if there are no more entries, the operation will return NT_STATUS_OK. 
01168                  * We want to return failure if no results were returned*/
01169                 return CAC_FAILURE;
01170         }
01171 
01172         if (num_groups_out) {
01173                 names_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out );
01174                 if ( !names_out ) {
01175                         hnd->status = NT_STATUS_NO_MEMORY;
01176                         TALLOC_FREE( acct_buf );
01177                         return CAC_FAILURE;
01178                 }
01179 
01180                 desc_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out );
01181                 if ( !desc_out ) {
01182                         hnd->status = NT_STATUS_NO_MEMORY;
01183                         TALLOC_FREE( acct_buf );
01184                         TALLOC_FREE( names_out );
01185                         return CAC_FAILURE;
01186                 }
01187 
01188                 rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out );
01189                 if ( !rids_out ) {
01190                         hnd->status = NT_STATUS_NO_MEMORY;
01191                         TALLOC_FREE( acct_buf );
01192                         TALLOC_FREE( names_out );
01193                         TALLOC_FREE( desc_out );
01194                         return CAC_FAILURE;
01195                 }
01196         } else {
01197                 names_out = NULL;
01198                 desc_out = NULL;
01199                 rids_out = NULL;
01200         }
01201 
01202         for ( i = 0; i < num_groups_out; i++ ) {
01203                 names_out[i] =
01204                         talloc_strdup( mem_ctx, acct_buf[i].acct_name );
01205                 desc_out[i] = talloc_strdup( mem_ctx, acct_buf[i].acct_desc );
01206                 rids_out[i] = acct_buf[i].rid;
01207 
01208                 if ( !names_out[i] || !desc_out[i] ) {
01209                         hnd->status = NT_STATUS_NO_MEMORY;
01210                         return CAC_FAILURE;
01211                 }
01212         }
01213 
01214         op->out.resume_idx = resume_idx_out;
01215         op->out.num_groups = num_groups_out;
01216         op->out.rids = rids_out;
01217         op->out.names = names_out;
01218         op->out.descriptions = desc_out;
01219 
01220         return CAC_SUCCESS;
01221 }

int cac_SamEnumAliases ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamEnumAliases op 
)

Enumerates domain aliases.

Can be used as a loop condition. Example: while(cac_SamEnumAliases(hnd, mem_ctx, op)) { ... }

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1223 行で定義されています。

参照先 _CACSERVERHANDLE::_internalacct_info::acct_descacct_info::acct_namecac_GetPipe()CacServerHandleInternal::ctxSamEnumAliases::descriptionsSamEnumAliases::dom_hndSamEnumAliases::doneSamEnumAliases::inSamEnumAliases::namesSamEnumAliases::num_aliasesSamEnumAliases::outCacServerHandleInternal::pipesSamEnumAliases::resume_idxacct_info::ridSamEnumAliases::ridsrpccli_samr_enum_als_groups()_CACSERVERHANDLE::statustalloc_strdup().

01225 {
01226         struct rpc_pipe_client *pipe_hnd = NULL;
01227 
01228         uint32 i = 0;
01229 
01230         uint32 resume_idx_out = 0;
01231         char **names_out = NULL;
01232         char **desc_out = NULL;
01233         uint32 *rids_out = NULL;
01234         uint32 num_als_out = 0;
01235 
01236         struct acct_info *acct_buf = NULL;
01237 
01238         if ( !hnd )
01239                 return CAC_FAILURE;
01240 
01241         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01242                 hnd->status = NT_STATUS_INVALID_HANDLE;
01243                 return CAC_FAILURE;
01244         }
01245 
01246         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
01247                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01248                 return CAC_FAILURE;
01249         }
01250 
01251         /*this is a hack.. but is the only reliable way to know if everything has been enumerated */
01252         if ( op->out.done == True ) {
01253                 return CAC_FAILURE;
01254         }
01255 
01256         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01257         if ( !pipe_hnd ) {
01258                 hnd->status = NT_STATUS_INVALID_HANDLE;
01259                 return CAC_FAILURE;
01260         }
01261 
01262         resume_idx_out = op->out.resume_idx;
01263 
01264         hnd->status =
01265                 rpccli_samr_enum_als_groups( pipe_hnd, mem_ctx,
01266                                              op->in.dom_hnd, &resume_idx_out,
01267                                              SAMR_ENUM_MAX_SIZE, &acct_buf,
01268                                              &num_als_out );
01269 
01270 
01271         if ( NT_STATUS_IS_OK( hnd->status ) )
01272                 op->out.done = True;
01273 
01274         /*if there are no more entries, the operation will return NT_STATUS_OK. 
01275          * We want to return failure if no results were returned*/
01276         if ( !NT_STATUS_IS_OK( hnd->status )
01277              && NT_STATUS_V( hnd->status ) !=
01278              NT_STATUS_V( STATUS_MORE_ENTRIES ) )
01279                 return CAC_FAILURE;
01280 
01281         if (num_als_out) {
01282                 names_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out );
01283                 if ( !names_out ) {
01284                         hnd->status = NT_STATUS_NO_MEMORY;
01285                         TALLOC_FREE( acct_buf );
01286                         return CAC_FAILURE;
01287                 }
01288 
01289                 desc_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out );
01290                 if ( !desc_out ) {
01291                         hnd->status = NT_STATUS_NO_MEMORY;
01292                         TALLOC_FREE( acct_buf );
01293                         TALLOC_FREE( names_out );
01294                         return CAC_FAILURE;
01295                 }
01296 
01297                 rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_als_out );
01298                 if ( !rids_out ) {
01299                         hnd->status = NT_STATUS_NO_MEMORY;
01300                         TALLOC_FREE( acct_buf );
01301                         TALLOC_FREE( names_out );
01302                         TALLOC_FREE( desc_out );
01303                         return CAC_FAILURE;
01304                 }
01305         } else {
01306                 names_out = NULL;
01307                 desc_out = NULL;
01308                 rids_out = NULL;
01309         }
01310 
01311         for ( i = 0; i < num_als_out; i++ ) {
01312                 names_out[i] =
01313                         talloc_strdup( mem_ctx, acct_buf[i].acct_name );
01314                 desc_out[i] = talloc_strdup( mem_ctx, acct_buf[i].acct_desc );
01315                 rids_out[i] = acct_buf[i].rid;
01316 
01317                 if ( !names_out[i] || !desc_out[i] ) {
01318                         hnd->status = NT_STATUS_NO_MEMORY;
01319                         return CAC_FAILURE;
01320                 }
01321         }
01322 
01323         op->out.resume_idx = resume_idx_out;
01324         op->out.num_aliases = num_als_out;
01325         op->out.rids = rids_out;
01326         op->out.names = names_out;
01327         op->out.descriptions = desc_out;
01328 
01329         return CAC_SUCCESS;
01330 }

int cac_SamCreateAlias ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamCreateAlias op 
)

Creates an alias.

If the alias already exists it will not be opened.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1332 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamCreateAlias::alias_hndcac_GetPipe()CacServerHandleInternal::ctxSamCreateAlias::dom_hndSamCreateAlias::inSamCreateAlias::nameSamCreateAlias::outCacServerHandleInternal::pipesrpccli_samr_create_dom_alias()_CACSERVERHANDLE::status.

01334 {
01335         struct rpc_pipe_client *pipe_hnd = NULL;
01336 
01337         POLICY_HND *als_hnd_out = NULL;
01338 
01339         if ( !hnd )
01340                 return CAC_FAILURE;
01341 
01342         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01343                 hnd->status = NT_STATUS_INVALID_HANDLE;
01344                 return CAC_FAILURE;
01345         }
01346 
01347         if ( !op || !op->in.name || op->in.name[0] == '\0' || !mem_ctx ) {
01348                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01349                 return CAC_FAILURE;
01350         }
01351 
01352         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01353         if ( !pipe_hnd ) {
01354                 hnd->status = NT_STATUS_INVALID_HANDLE;
01355                 return CAC_FAILURE;
01356         }
01357 
01358         als_hnd_out = talloc( mem_ctx, POLICY_HND );
01359         if ( !als_hnd_out ) {
01360                 hnd->status = NT_STATUS_NO_MEMORY;
01361                 return CAC_FAILURE;
01362         }
01363 
01364         hnd->status =
01365                 rpccli_samr_create_dom_alias( pipe_hnd, mem_ctx,
01366                                               op->in.dom_hnd, op->in.name,
01367                                               als_hnd_out );
01368 
01369         if ( !NT_STATUS_IS_OK( hnd->status ) )
01370                 return CAC_FAILURE;
01371 
01372         op->out.alias_hnd = als_hnd_out;
01373 
01374         return CAC_SUCCESS;
01375 
01376 }

int cac_SamOpenAlias ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamOpenAlias op 
)

Opens a handle to an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1378 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamOpenAlias::accessSamOpenAlias::alias_hndcac_GetPipe()CacServerHandleInternal::ctxSamOpenAlias::dom_hndSamOpenAlias::inSamOpenAlias::outCacServerHandleInternal::pipesSamOpenAlias::ridrpccli_samr_open_alias()_CACSERVERHANDLE::status.

01380 {
01381         struct rpc_pipe_client *pipe_hnd = NULL;
01382 
01383         POLICY_HND *als_hnd_out = NULL;
01384 
01385         if ( !hnd )
01386                 return CAC_FAILURE;
01387 
01388         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01389                 hnd->status = NT_STATUS_INVALID_HANDLE;
01390                 return CAC_FAILURE;
01391         }
01392 
01393         if ( !op || op->in.access == 0 || op->in.rid == 0 || !mem_ctx ) {
01394                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01395                 return CAC_FAILURE;
01396         }
01397 
01398         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01399         if ( !pipe_hnd ) {
01400                 hnd->status = NT_STATUS_INVALID_HANDLE;
01401                 return CAC_FAILURE;
01402         }
01403 
01404         als_hnd_out = talloc( mem_ctx, POLICY_HND );
01405         if ( !als_hnd_out ) {
01406                 hnd->status = NT_STATUS_NO_MEMORY;
01407                 return CAC_FAILURE;
01408         }
01409 
01410         hnd->status =
01411                 rpccli_samr_open_alias( pipe_hnd, mem_ctx, op->in.dom_hnd,
01412                                         op->in.access, op->in.rid,
01413                                         als_hnd_out );
01414 
01415         if ( !NT_STATUS_IS_OK( hnd->status ) )
01416                 return CAC_FAILURE;
01417 
01418         op->out.alias_hnd = als_hnd_out;
01419 
01420         return CAC_SUCCESS;
01421 }

int cac_SamDeleteAlias ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND alias_hnd 
)

Deletes an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
alias_hnd Open handle to the alias
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1423 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesrpccli_samr_delete_dom_alias()_CACSERVERHANDLE::status.

01425 {
01426         struct rpc_pipe_client *pipe_hnd = NULL;
01427 
01428         if ( !hnd )
01429                 return CAC_FAILURE;
01430 
01431         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01432                 hnd->status = NT_STATUS_INVALID_HANDLE;
01433                 return CAC_FAILURE;
01434         }
01435 
01436         if ( !alias_hnd || !mem_ctx ) {
01437                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01438                 return CAC_FAILURE;
01439         }
01440 
01441         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01442         if ( !pipe_hnd ) {
01443                 hnd->status = NT_STATUS_INVALID_HANDLE;
01444                 return CAC_FAILURE;
01445         }
01446 
01447         hnd->status =
01448                 rpccli_samr_delete_dom_alias( pipe_hnd, mem_ctx, alias_hnd );
01449 
01450         if ( !NT_STATUS_IS_OK( hnd->status ) )
01451                 return CAC_FAILURE;
01452 
01453         return CAC_SUCCESS;
01454 
01455 }

int cac_SamAddAliasMember ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamAddAliasMember op 
)

Adds an account to an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1457 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamAddAliasMember::alias_hndcac_GetPipe()CacServerHandleInternal::ctxSamAddAliasMember::inCacServerHandleInternal::pipesrpccli_samr_add_aliasmem()SamAddAliasMember::sid_CACSERVERHANDLE::status.

01459 {
01460         struct rpc_pipe_client *pipe_hnd = NULL;
01461 
01462         if ( !hnd )
01463                 return CAC_FAILURE;
01464 
01465         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01466                 hnd->status = NT_STATUS_INVALID_HANDLE;
01467                 return CAC_FAILURE;
01468         }
01469 
01470         if ( !op || !op->in.alias_hnd || !op->in.sid || !mem_ctx ) {
01471                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01472                 return CAC_FAILURE;
01473         }
01474 
01475         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01476         if ( !pipe_hnd ) {
01477                 hnd->status = NT_STATUS_INVALID_HANDLE;
01478                 return CAC_FAILURE;
01479         }
01480 
01481         hnd->status =
01482                 rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd,
01483                                           op->in.sid );
01484 
01485         if ( !NT_STATUS_IS_OK( hnd->status ) )
01486                 return CAC_FAILURE;
01487 
01488         return CAC_SUCCESS;
01489 }

int cac_SamRemoveAliasMember ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamRemoveAliasMember op 
)

Removes an account from an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1491 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamRemoveAliasMember::alias_hndcac_GetPipe()CacServerHandleInternal::ctxSamRemoveAliasMember::inCacServerHandleInternal::pipesrpccli_samr_del_aliasmem()SamRemoveAliasMember::sid_CACSERVERHANDLE::status.

01493 {
01494         struct rpc_pipe_client *pipe_hnd = NULL;
01495 
01496         if ( !hnd )
01497                 return CAC_FAILURE;
01498 
01499         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01500                 hnd->status = NT_STATUS_INVALID_HANDLE;
01501                 return CAC_FAILURE;
01502         }
01503 
01504         if ( !op || !op->in.alias_hnd || !op->in.sid || !mem_ctx ) {
01505                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01506                 return CAC_FAILURE;
01507         }
01508 
01509         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01510         if ( !pipe_hnd ) {
01511                 hnd->status = NT_STATUS_INVALID_HANDLE;
01512                 return CAC_FAILURE;
01513         }
01514 
01515         hnd->status =
01516                 rpccli_samr_del_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd,
01517                                           op->in.sid );
01518 
01519         if ( !NT_STATUS_IS_OK( hnd->status ) )
01520                 return CAC_FAILURE;
01521 
01522         return CAC_SUCCESS;
01523 }

int cac_SamGetAliasMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetAliasMembers op 
)

Retrieves a list of all accounts in an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1525 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamGetAliasMembers::alias_hndcac_GetPipe()CacServerHandleInternal::ctxSamGetAliasMembers::inSamGetAliasMembers::num_membersSamGetAliasMembers::outCacServerHandleInternal::pipesrpccli_samr_query_aliasmem()SamGetAliasMembers::sids_CACSERVERHANDLE::status.

01527 {
01528         struct rpc_pipe_client *pipe_hnd = NULL;
01529 
01530         uint32 num_mem_out;
01531         DOM_SID *sids_out;
01532 
01533         if ( !hnd )
01534                 return CAC_FAILURE;
01535 
01536         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01537                 hnd->status = NT_STATUS_INVALID_HANDLE;
01538                 return CAC_FAILURE;
01539         }
01540 
01541         if ( !op || !op->in.alias_hnd || !mem_ctx ) {
01542                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01543                 return CAC_FAILURE;
01544         }
01545 
01546         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01547         if ( !pipe_hnd ) {
01548                 hnd->status = NT_STATUS_INVALID_HANDLE;
01549                 return CAC_FAILURE;
01550         }
01551 
01552         hnd->status =
01553                 rpccli_samr_query_aliasmem( pipe_hnd, mem_ctx,
01554                                             op->in.alias_hnd, &num_mem_out,
01555                                             &sids_out );
01556 
01557         if ( !NT_STATUS_IS_OK( hnd->status ) )
01558                 return CAC_FAILURE;
01559 
01560         op->out.num_members = num_mem_out;
01561         op->out.sids = sids_out;
01562 
01563         return CAC_SUCCESS;
01564 }

int cac_SamClearAliasMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND alias_hnd 
)

Removes all the members of an alias - warning: if this function fails is is possible that some but not all members were removed

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
alias_hnd Handle to the alias to clear
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1566 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxCacServerHandleInternal::pipesresultrpccli_samr_add_aliasmem()rpccli_samr_del_aliasmem()rpccli_samr_query_aliasmem()status_CACSERVERHANDLE::status.

参照元 cac_SamSetAliasMembers().

01568 {
01569         struct rpc_pipe_client *pipe_hnd = NULL;
01570 
01571         int result = CAC_SUCCESS;
01572 
01573         int i = 0;
01574 
01575         uint32 num_mem = 0;
01576         DOM_SID *sid = NULL;
01577 
01578         NTSTATUS status;
01579 
01580         if ( !hnd )
01581                 return CAC_FAILURE;
01582 
01583         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01584                 hnd->status = NT_STATUS_INVALID_HANDLE;
01585                 return CAC_FAILURE;
01586         }
01587 
01588         if ( !alias_hnd || !mem_ctx ) {
01589                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01590                 return CAC_FAILURE;
01591         }
01592 
01593         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01594         if ( !pipe_hnd ) {
01595                 hnd->status = NT_STATUS_INVALID_HANDLE;
01596                 return CAC_FAILURE;
01597         }
01598 
01599         hnd->status =
01600                 rpccli_samr_query_aliasmem( pipe_hnd, mem_ctx, alias_hnd,
01601                                             &num_mem, &sid );
01602 
01603         if ( !NT_STATUS_IS_OK( hnd->status ) )
01604                 return CAC_FAILURE;
01605 
01606         /*try to delete the users one by one */
01607         for ( i = 0; i < num_mem && NT_STATUS_IS_OK( hnd->status ); i++ ) {
01608                 hnd->status =
01609                         rpccli_samr_del_aliasmem( pipe_hnd, mem_ctx,
01610                                                   alias_hnd, &sid[i] );
01611         }
01612 
01613         /*if not all members could be removed, then try to re-add the members that were already deleted */
01614         if ( !NT_STATUS_IS_OK( hnd->status ) ) {
01615                 status = NT_STATUS_OK;
01616 
01617                 for ( i -= 1; i >= 0 && NT_STATUS_IS_OK( status ); i-- ) {
01618                         status = rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx,
01619                                                            alias_hnd,
01620                                                            &sid[i] );
01621                 }
01622 
01623                 /*we return with the NTSTATUS error that we got when trying to delete users */
01624                 if ( !NT_STATUS_IS_OK( status ) )
01625                         result = CAC_FAILURE;
01626         }
01627 
01628         TALLOC_FREE( sid );
01629         return result;
01630 }

int cac_SamSetAliasMembers ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetAliasMembers op 
)

Clears the members of an alias and adds a list of members to the alias

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1632 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamSetAliasMembers::alias_hndcac_GetPipe()cac_SamClearAliasMembers()CacServerHandleInternal::ctxSamSetAliasMembers::inSamSetAliasMembers::num_membersCacServerHandleInternal::pipesrpccli_samr_add_aliasmem()SamSetAliasMembers::sids_CACSERVERHANDLE::status.

01634 {
01635         struct rpc_pipe_client *pipe_hnd = NULL;
01636 
01637         uint32 i = 0;
01638 
01639         if ( !hnd )
01640                 return CAC_FAILURE;
01641 
01642         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01643                 hnd->status = NT_STATUS_INVALID_HANDLE;
01644                 return CAC_FAILURE;
01645         }
01646 
01647         if ( !op || !op->in.alias_hnd || !mem_ctx ) {
01648                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01649                 return CAC_FAILURE;
01650         }
01651 
01652         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01653         if ( !pipe_hnd ) {
01654                 hnd->status = NT_STATUS_INVALID_HANDLE;
01655                 return CAC_FAILURE;
01656         }
01657 
01658         /*use cac_SamClearAliasMembers() to clear them */
01659         if ( !cac_SamClearAliasMembers( hnd, mem_ctx, op->in.alias_hnd ) )
01660                 return CAC_FAILURE;     /*hnd->status is already set */
01661 
01662 
01663         for ( i = 0; i < op->in.num_members && NT_STATUS_IS_OK( hnd->status );
01664               i++ ) {
01665                 hnd->status =
01666                         rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx,
01667                                                   op->in.alias_hnd,
01668                                                   &( op->in.sids[i] ) );
01669         }
01670 
01671         if ( !NT_STATUS_IS_OK( hnd->status ) )
01672                 return CAC_FAILURE;
01673 
01674         return CAC_SUCCESS;
01675 
01676 }

int cac_SamUserChangePasswd ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamUserChangePasswd op 
)

Used by a user to change their password

cac_samr.c1678 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_GetServer()_SMBCSRV::clicli_rpc_pipe_open_noauth()CacServerHandleInternal::ctxSamUserChangePasswd::inSamUserChangePasswd::new_passwordSamUserChangePasswd::passwordCacServerHandleInternal::pipesrpccli_samr_chgpasswd_user()_CACSERVERHANDLE::statusSamUserChangePasswd::username.

01680 {
01681         SMBCSRV *srv = NULL;
01682         struct rpc_pipe_client *pipe_hnd = NULL;
01683 
01684         if ( !hnd )
01685                 return CAC_FAILURE;
01686 
01687         if ( !hnd->_internal.ctx ) {
01688                 hnd->status = NT_STATUS_INVALID_HANDLE;
01689                 return CAC_FAILURE;
01690         }
01691 
01692         if ( !op || !op->in.username || !op->in.password
01693              || !op->in.new_password || !mem_ctx ) {
01694                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01695                 return CAC_FAILURE;
01696         }
01697 
01698         srv = cac_GetServer( hnd );
01699         if ( !srv ) {
01700                 hnd->status = NT_STATUS_INVALID_CONNECTION;
01701                 return CAC_FAILURE;
01702         }
01703 
01704         /*open a session on SAMR if we don't have one */
01705         if ( !hnd->_internal.pipes[PI_SAMR] ) {
01706                 if ( !
01707                      ( pipe_hnd =
01708                        cli_rpc_pipe_open_noauth( srv->cli, PI_SAMR,
01709                                                  &hnd->status ) ) ) {
01710                         return CAC_FAILURE;
01711                 }
01712 
01713                 hnd->_internal.pipes[PI_SAMR] = True;
01714         }
01715 
01716         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01717         if ( !pipe_hnd ) {
01718                 hnd->status = NT_STATUS_INVALID_HANDLE;
01719                 return CAC_FAILURE;
01720         }
01721 
01722         hnd->status =
01723                 rpccli_samr_chgpasswd_user( pipe_hnd, mem_ctx,
01724                                             op->in.username,
01725                                             op->in.new_password,
01726                                             op->in.password );
01727 
01728         if ( !NT_STATUS_IS_OK( hnd->status ) )
01729                 return CAC_FAILURE;
01730 
01731         return CAC_SUCCESS;
01732 }

int cac_SamEnableUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND user_hnd 
)

Enables a user

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
user_hnd Open handle to the user to enable
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

check the ACB mask

cac_samr.c1734 行で定義されています。

参照先 _CACSERVERHANDLE::_internalsam_user_info_16::acb_infocac_GetPipe()cac_GetServer()_SMBCSRV::cliCacServerHandleInternal::ctxsam_userinfo_ctr_info::id16sam_userinfo_ctr_info::infoCacServerHandleInternal::pipesrpccli_samr_query_userinfo()rpccli_samr_set_userinfo2()_CACSERVERHANDLE::statuscli_state::user_session_key.

01736 {
01737         SMBCSRV *srv = NULL;
01738         struct rpc_pipe_client *pipe_hnd = NULL;
01739 
01740         SAM_USERINFO_CTR *ctr;
01741 
01742         if ( !hnd )
01743                 return CAC_FAILURE;
01744 
01745         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01746                 hnd->status = NT_STATUS_INVALID_HANDLE;
01747                 return CAC_FAILURE;
01748         }
01749 
01750         if ( !user_hnd || !mem_ctx ) {
01751                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01752                 return CAC_FAILURE;
01753         }
01754 
01755         srv = cac_GetServer( hnd );
01756         if ( !srv ) {
01757                 hnd->status = NT_STATUS_INVALID_CONNECTION;
01758                 return CAC_FAILURE;
01759         }
01760 
01761         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01762         if ( !pipe_hnd ) {
01763                 hnd->status = NT_STATUS_INVALID_HANDLE;
01764                 return CAC_FAILURE;
01765         }
01766 
01767         /*info_level = 21 is the only level that I have found to work reliably. It would be nice if user_level = 10 worked. */
01768         hnd->status =
01769                 rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10,
01770                                             &ctr );
01771 
01772         if ( !NT_STATUS_IS_OK( hnd->status ) )
01773                 return CAC_FAILURE;
01774 
01775    /**check the ACB mask*/
01776         if ( ( ctr->info.id16->acb_info & ACB_DISABLED ) == ACB_DISABLED ) {
01777                 /*toggle the disabled bit */
01778                 ctr->info.id16->acb_info ^= ACB_DISABLED;
01779         } else {
01780                 /*the user is already enabled so just return success */
01781                 return CAC_SUCCESS;
01782         }
01783 
01784         /*now set the userinfo */
01785         hnd->status =
01786                 rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10,
01787                                            &srv->cli->user_session_key, ctr );
01788 
01789         /*this will only work properly if we use set_userinfo2 - fail if it is not supported */
01790         if ( !NT_STATUS_IS_OK( hnd->status ) )
01791                 return CAC_FAILURE;
01792 
01793         return CAC_SUCCESS;
01794 }

int cac_SamDisableUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
POLICY_HND user_hnd 
)

Disables a user

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
user_hnd Open handle to the user to disables
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1796 行で定義されています。

参照先 _CACSERVERHANDLE::_internalsam_user_info_16::acb_infocac_GetPipe()cac_GetServer()_SMBCSRV::cliCacServerHandleInternal::ctxsam_userinfo_ctr_info::id16sam_userinfo_ctr_info::infoCacServerHandleInternal::pipesrpccli_samr_query_userinfo()rpccli_samr_set_userinfo2()_CACSERVERHANDLE::statuscli_state::user_session_key.

01798 {
01799         SMBCSRV *srv = NULL;
01800         struct rpc_pipe_client *pipe_hnd = NULL;
01801 
01802         SAM_USERINFO_CTR *ctr;
01803 
01804         if ( !hnd )
01805                 return CAC_FAILURE;
01806 
01807         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01808                 hnd->status = NT_STATUS_INVALID_HANDLE;
01809                 return CAC_FAILURE;
01810         }
01811 
01812         if ( !user_hnd || !mem_ctx ) {
01813                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01814                 return CAC_FAILURE;
01815         }
01816 
01817         srv = cac_GetServer( hnd );
01818         if ( !srv ) {
01819                 hnd->status = NT_STATUS_INVALID_CONNECTION;
01820                 return CAC_FAILURE;
01821         }
01822 
01823         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01824         if ( !pipe_hnd ) {
01825                 hnd->status = NT_STATUS_INVALID_HANDLE;
01826                 return CAC_FAILURE;
01827         }
01828 
01829         hnd->status =
01830                 rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10,
01831                                             &ctr );
01832 
01833         if ( !NT_STATUS_IS_OK( hnd->status ) )
01834                 return CAC_FAILURE;
01835 
01836         if ( ( ctr->info.id16->acb_info & ACB_DISABLED ) == ACB_DISABLED ) {
01837                 /*then the user is already disabled */
01838                 return CAC_SUCCESS;
01839         }
01840 
01841         /*toggle the disabled bit */
01842         ctr->info.id16->acb_info ^= ACB_DISABLED;
01843 
01844         /*this will only work properly if we use set_userinfo2 */
01845         hnd->status =
01846                 rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10,
01847                                            &srv->cli->user_session_key, ctr );
01848 
01849         /*this will only work properly if we use set_userinfo2 fail if it is not supported */
01850         if ( !NT_STATUS_IS_OK( hnd->status ) )
01851                 return CAC_FAILURE;
01852 
01853         return CAC_SUCCESS;
01854 }

int cac_SamSetPassword ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetPassword op 
)

Sets a user's password

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1856 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_GetServer()_SMBCSRV::cliCacServerHandleInternal::ctxencode_pw_buffer()sam_userinfo_ctr_info::id24SamSetPassword::insam_userinfo_ctr_info::infoinit_sam_user_info24()SamSetPassword::passwordCacServerHandleInternal::pipesrpccli_samr_set_userinfo()_CACSERVERHANDLE::statussam_userinfo_ctr_info::switch_valueSamSetPassword::user_hndcli_state::user_session_key.

01858 {
01859         SMBCSRV *srv = NULL;
01860         struct rpc_pipe_client *pipe_hnd = NULL;
01861 
01862         SAM_USERINFO_CTR ctr;
01863         SAM_USER_INFO_24 info24;
01864         uint8 pw[516];
01865 
01866         if ( !hnd )
01867                 return CAC_FAILURE;
01868 
01869         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01870                 hnd->status = NT_STATUS_INVALID_HANDLE;
01871                 return CAC_FAILURE;
01872         }
01873 
01874         if ( !op->in.user_hnd || !op->in.password || !mem_ctx ) {
01875                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01876                 return CAC_FAILURE;
01877         }
01878 
01879         srv = cac_GetServer( hnd );
01880         if ( !srv ) {
01881                 hnd->status = NT_STATUS_INVALID_CONNECTION;
01882                 return CAC_FAILURE;
01883         }
01884 
01885         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01886         if ( !pipe_hnd ) {
01887                 hnd->status = NT_STATUS_INVALID_HANDLE;
01888                 return CAC_FAILURE;
01889         }
01890 
01891         ZERO_STRUCT( ctr );
01892         ZERO_STRUCT( info24 );
01893 
01894         encode_pw_buffer( pw, op->in.password, STR_UNICODE );
01895 
01896         init_sam_user_info24( &info24, ( char * ) pw, 24 );
01897 
01898         ctr.switch_value = 24;
01899         ctr.info.id24 = &info24;
01900 
01901         hnd->status =
01902                 rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
01903                                           24, &srv->cli->user_session_key,
01904                                           &ctr );
01905 
01906         if ( !NT_STATUS_IS_OK( hnd->status ) )
01907                 return CAC_FAILURE;
01908 
01909         return CAC_SUCCESS;
01910 }

int cac_SamGetUserInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetUserInfo op 
)

Retrieves user information using a CacUserInfo structure.

If you would like to use a SAM_USERINFO_CTR directly, use cac_SamGetUserInfoCtr()

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
cac_SamGetUserInfoCtr()
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1912 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_MakeUserInfo()CacServerHandleInternal::ctxSamGetUserInfo::inSamGetUserInfo::infoSamGetUserInfo::outCacServerHandleInternal::pipesrpccli_samr_query_userinfo()_CACSERVERHANDLE::statusSamGetUserInfo::user_hnd.

01914 {
01915         struct rpc_pipe_client *pipe_hnd = NULL;
01916 
01917         SAM_USERINFO_CTR *ctr;
01918 
01919         if ( !hnd )
01920                 return CAC_FAILURE;
01921 
01922         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01923                 hnd->status = NT_STATUS_INVALID_HANDLE;
01924                 return CAC_FAILURE;
01925         }
01926 
01927         if ( !op->in.user_hnd || !mem_ctx ) {
01928                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01929                 return CAC_FAILURE;
01930         }
01931 
01932         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01933         if ( !pipe_hnd ) {
01934                 hnd->status = NT_STATUS_INVALID_HANDLE;
01935                 return CAC_FAILURE;
01936         }
01937 
01938         hnd->status =
01939                 rpccli_samr_query_userinfo( pipe_hnd, mem_ctx,
01940                                             op->in.user_hnd, 21, &ctr );
01941 
01942         if ( !NT_STATUS_IS_OK( hnd->status ) )
01943                 return CAC_FAILURE;
01944 
01945         op->out.info = cac_MakeUserInfo( mem_ctx, ctr );
01946 
01947         if ( !op->out.info ) {
01948                 hnd->status = NT_STATUS_NO_MEMORY;
01949                 return CAC_FAILURE;
01950         }
01951 
01952         return CAC_SUCCESS;
01953 }

int cac_SamSetUserInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetUserInfo op 
)

Sets the user info using a CacUserInfo structure.

If you would like to use a SAM_USERINFO_CTR directly use cac_SamSetUserInfoCtr().

覚え書き:
All fields in the CacUserInfo structure will be set. Best to call cac_GetUserInfo() modify fields that you want, and then call cac_SetUserInfo().

When calling this, you _must_ set the user's password.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
cac_SamSetUserInfoCtr()
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c1955 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_GetServer()cac_MakeUserInfoCtr()_SMBCSRV::cliCacServerHandleInternal::ctxSamSetUserInfo::inSamSetUserInfo::infoCacServerHandleInternal::pipesrpccli_samr_set_userinfo()rpccli_samr_set_userinfo2()CacServerHandleInternal::srv_level_CACSERVERHANDLE::statusSamSetUserInfo::user_hndcli_state::user_session_key.

01957 {
01958         SMBCSRV *srv = NULL;
01959         struct rpc_pipe_client *pipe_hnd = NULL;
01960 
01961         SAM_USERINFO_CTR *ctr;
01962 
01963         if ( !hnd )
01964                 return CAC_FAILURE;
01965 
01966         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
01967                 hnd->status = NT_STATUS_INVALID_HANDLE;
01968                 return CAC_FAILURE;
01969         }
01970 
01971         if ( !op->in.user_hnd || !op->in.info || !mem_ctx ) {
01972                 hnd->status = NT_STATUS_INVALID_PARAMETER;
01973                 return CAC_FAILURE;
01974         }
01975 
01976         ctr = cac_MakeUserInfoCtr( mem_ctx, op->in.info );
01977         if ( !ctr ) {
01978                 hnd->status = NT_STATUS_NO_MEMORY;
01979                 return CAC_FAILURE;
01980         }
01981 
01982         srv = cac_GetServer( hnd );
01983         if ( !srv ) {
01984                 hnd->status = NT_STATUS_INVALID_CONNECTION;
01985                 return CAC_FAILURE;
01986         }
01987 
01988         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
01989         if ( !pipe_hnd ) {
01990                 hnd->status = NT_STATUS_INVALID_HANDLE;
01991                 return CAC_FAILURE;
01992         }
01993 
01994         if ( hnd->_internal.srv_level >= SRV_WIN_NT4 ) {
01995                 hnd->status =
01996                         rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx,
01997                                                    op->in.user_hnd, 21,
01998                                                    &srv->cli->
01999                                                    user_session_key, ctr );
02000         }
02001 
02002         if ( hnd->_internal.srv_level < SRV_WIN_NT4
02003              || !NT_STATUS_IS_OK( hnd->status ) ) {
02004                 hnd->status =
02005                         rpccli_samr_set_userinfo( pipe_hnd, mem_ctx,
02006                                                   op->in.user_hnd, 21,
02007                                                   &srv->cli->user_session_key,
02008                                                   ctr );
02009 
02010                 if ( NT_STATUS_IS_OK( hnd->status )
02011                      && hnd->_internal.srv_level > SRV_WIN_NT4 ) {
02012                         hnd->_internal.srv_level = SRV_WIN_NT4;
02013                 }
02014         }
02015 
02016 
02017         if ( !NT_STATUS_IS_OK( hnd->status ) )
02018                 return CAC_FAILURE;
02019 
02020         return CAC_SUCCESS;
02021 }

int cac_SamGetUserInfoCtr ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetUserInfoCtr op 
)

Retrieves user information using a SAM_USERINFO_CTR structure.

If you don't want to use this structure, user SamGetUserInfo()

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
cac_SamGetUserInfo()
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2024 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()SamGetUserInfoCtr::ctrCacServerHandleInternal::ctxSamGetUserInfoCtr::inSamGetUserInfoCtr::info_classSamGetUserInfoCtr::outCacServerHandleInternal::pipesrpccli_samr_query_userinfo()_CACSERVERHANDLE::statusSamGetUserInfoCtr::user_hnd.

02026 {
02027         struct rpc_pipe_client *pipe_hnd = NULL;
02028 
02029         SAM_USERINFO_CTR *ctr_out;
02030 
02031         if ( !hnd )
02032                 return CAC_FAILURE;
02033 
02034         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02035                 hnd->status = NT_STATUS_INVALID_HANDLE;
02036                 return CAC_FAILURE;
02037         }
02038 
02039         if ( !op->in.user_hnd || op->in.info_class == 0 || !mem_ctx ) {
02040                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02041                 return CAC_FAILURE;
02042         }
02043 
02044         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02045         if ( !pipe_hnd ) {
02046                 hnd->status = NT_STATUS_INVALID_HANDLE;
02047                 return CAC_FAILURE;
02048         }
02049 
02050         hnd->status =
02051                 rpccli_samr_query_userinfo( pipe_hnd, mem_ctx,
02052                                             op->in.user_hnd,
02053                                             op->in.info_class, &ctr_out );
02054 
02055         if ( !NT_STATUS_IS_OK( hnd->status ) )
02056                 return CAC_FAILURE;
02057 
02058         op->out.ctr = ctr_out;
02059 
02060         return CAC_SUCCESS;
02061 }

int cac_SamSetUserInfoCtr ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetUserInfoCtr op 
)

Sets the user info using a SAM_USERINFO_CTR structure.

If you don't want to use this structure, use cac_SamSetUserInfo()

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
cac_SamSetUserInfo()
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2063 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_GetServer()_SMBCSRV::cliSamSetUserInfoCtr::ctrCacServerHandleInternal::ctxSamSetUserInfoCtr::inCacServerHandleInternal::pipesrpccli_samr_set_userinfo()_CACSERVERHANDLE::statussam_userinfo_ctr_info::switch_valueSamSetUserInfoCtr::user_hndcli_state::user_session_key.

02065 {
02066         SMBCSRV *srv = NULL;
02067         struct rpc_pipe_client *pipe_hnd = NULL;
02068 
02069         if ( !hnd )
02070                 return CAC_FAILURE;
02071 
02072         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02073                 hnd->status = NT_STATUS_INVALID_HANDLE;
02074                 return CAC_FAILURE;
02075         }
02076 
02077         if ( !op->in.user_hnd || !op->in.ctr || !mem_ctx ) {
02078                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02079                 return CAC_FAILURE;
02080         }
02081 
02082         srv = cac_GetServer( hnd );
02083         if ( !srv ) {
02084                 hnd->status = NT_STATUS_INVALID_CONNECTION;
02085                 return CAC_FAILURE;
02086         }
02087 
02088         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02089         if ( !pipe_hnd ) {
02090                 hnd->status = NT_STATUS_INVALID_HANDLE;
02091                 return CAC_FAILURE;
02092         }
02093 
02094 
02095         hnd->status =
02096                 rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
02097                                           op->in.ctr->switch_value,
02098                                           &srv->cli->user_session_key,
02099                                           op->in.ctr );
02100 
02101         if ( !NT_STATUS_IS_OK( hnd->status ) )
02102                 return CAC_FAILURE;
02103 
02104         return CAC_SUCCESS;
02105 
02106 }

int cac_SamRenameUser ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamRenameUser op 
)

Changes the name of a user.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2108 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_GetServer()_SMBCSRV::cliCacServerHandleInternal::ctxsam_userinfo_ctr_info::id7SamRenameUser::insam_userinfo_ctr_info::infoinit_sam_user_info7()SamRenameUser::new_nameCacServerHandleInternal::pipesrpccli_samr_set_userinfo()_CACSERVERHANDLE::statussam_userinfo_ctr_info::switch_valueSamRenameUser::user_hndcli_state::user_session_key.

02110 {
02111         SMBCSRV *srv = NULL;
02112         struct rpc_pipe_client *pipe_hnd = NULL;
02113 
02114         SAM_USERINFO_CTR ctr;
02115         SAM_USER_INFO_7 info7;
02116 
02117         if ( !hnd )
02118                 return CAC_FAILURE;
02119 
02120         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02121                 hnd->status = NT_STATUS_INVALID_HANDLE;
02122                 return CAC_FAILURE;
02123         }
02124 
02125         if ( !op->in.user_hnd || !op->in.new_name
02126              || op->in.new_name[0] == '\0' || !mem_ctx ) {
02127                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02128                 return CAC_FAILURE;
02129         }
02130 
02131         srv = cac_GetServer( hnd );
02132         if ( !srv ) {
02133                 hnd->status = NT_STATUS_INVALID_CONNECTION;
02134                 return CAC_FAILURE;
02135         }
02136 
02137         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02138         if ( !pipe_hnd ) {
02139                 hnd->status = NT_STATUS_INVALID_HANDLE;
02140                 return CAC_FAILURE;
02141         }
02142 
02143         ZERO_STRUCT( ctr );
02144         ZERO_STRUCT( info7 );
02145 
02146         init_sam_user_info7( &info7, op->in.new_name );
02147 
02148         ctr.switch_value = 7;
02149         ctr.info.id7 = &info7;
02150 
02151         hnd->status =
02152                 rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd,
02153                                           7, &srv->cli->user_session_key,
02154                                           &ctr );
02155 
02156         if ( !NT_STATUS_IS_OK( hnd->status ) )
02157                 return CAC_FAILURE;
02158 
02159         return CAC_SUCCESS;
02160 }

int cac_SamGetGroupInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetGroupInfo op 
)

Retrieves information about a group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2163 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_MakeGroupInfo()CacServerHandleInternal::ctxSamGetGroupInfo::group_hndSamGetGroupInfo::inSamGetGroupInfo::infoSamGetGroupInfo::outCacServerHandleInternal::pipesrpccli_samr_query_groupinfo()_CACSERVERHANDLE::status.

02165 {
02166         struct rpc_pipe_client *pipe_hnd = NULL;
02167 
02168         GROUP_INFO_CTR *ctr;
02169 
02170         if ( !hnd )
02171                 return CAC_FAILURE;
02172 
02173         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02174                 hnd->status = NT_STATUS_INVALID_HANDLE;
02175                 return CAC_FAILURE;
02176         }
02177 
02178         if ( !op->in.group_hnd || !mem_ctx ) {
02179                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02180                 return CAC_FAILURE;
02181         }
02182 
02183         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02184         if ( !pipe_hnd ) {
02185                 hnd->status = NT_STATUS_INVALID_HANDLE;
02186                 return CAC_FAILURE;
02187         }
02188 
02189 
02190         /*get a GROUP_INFO_1 structure */
02191         hnd->status =
02192                 rpccli_samr_query_groupinfo( pipe_hnd, mem_ctx,
02193                                              op->in.group_hnd, 1, &ctr );
02194 
02195         if ( !NT_STATUS_IS_OK( hnd->status ) )
02196                 return CAC_FAILURE;
02197 
02198         op->out.info = cac_MakeGroupInfo( mem_ctx, ctr );
02199         if ( !op->out.info ) {
02200                 hnd->status = NT_STATUS_NO_MEMORY;
02201                 return CAC_FAILURE;
02202         }
02203 
02204         return CAC_SUCCESS;
02205 }

int cac_SamSetGroupInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetGroupInfo op 
)

Sets information about a group.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2207 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_MakeGroupInfoCtr()CacServerHandleInternal::ctxSamSetGroupInfo::group_hndSamSetGroupInfo::inSamSetGroupInfo::infoCacServerHandleInternal::pipesrpccli_samr_set_groupinfo()_CACSERVERHANDLE::status.

02209 {
02210         struct rpc_pipe_client *pipe_hnd = NULL;
02211 
02212         GROUP_INFO_CTR *ctr = NULL;
02213 
02214         if ( !hnd )
02215                 return CAC_FAILURE;
02216 
02217         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02218                 hnd->status = NT_STATUS_INVALID_HANDLE;
02219                 return CAC_FAILURE;
02220         }
02221 
02222         if ( !op->in.group_hnd || !op->in.info || !mem_ctx ) {
02223                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02224                 return CAC_FAILURE;
02225         }
02226 
02227         ctr = cac_MakeGroupInfoCtr( mem_ctx, op->in.info );
02228         if ( !ctr ) {
02229                 hnd->status = NT_STATUS_NO_MEMORY;
02230                 return CAC_FAILURE;
02231         }
02232 
02233         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02234         if ( !pipe_hnd ) {
02235                 hnd->status = NT_STATUS_INVALID_HANDLE;
02236                 return CAC_FAILURE;
02237         }
02238 
02239         hnd->status =
02240                 rpccli_samr_set_groupinfo( pipe_hnd, mem_ctx,
02241                                            op->in.group_hnd, ctr );
02242 
02243         if ( !NT_STATUS_IS_OK( hnd->status ) )
02244                 return CAC_FAILURE;
02245 
02246         return CAC_SUCCESS;
02247 }

int cac_SamRenameGroup ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamRenameGroup op 
)

Changes the name of a group

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2249 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxgroup_info_ctr::groupSamRenameGroup::group_hndSamRenameGroup::ingroup_info_ctr::info2init_samr_group_info2()SamRenameGroup::new_nameCacServerHandleInternal::pipesrpccli_samr_set_groupinfo()_CACSERVERHANDLE::statusgroup_info_ctr::switch_value1.

02251 {
02252         struct rpc_pipe_client *pipe_hnd = NULL;
02253 
02254         GROUP_INFO_CTR ctr;
02255 
02256         if ( !hnd )
02257                 return CAC_FAILURE;
02258 
02259         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02260                 hnd->status = NT_STATUS_INVALID_HANDLE;
02261                 return CAC_FAILURE;
02262         }
02263 
02264         if ( !op->in.group_hnd || !op->in.new_name
02265              || op->in.new_name[0] == '\0' || !mem_ctx ) {
02266                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02267                 return CAC_FAILURE;
02268         }
02269 
02270         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02271         if ( !pipe_hnd ) {
02272                 hnd->status = NT_STATUS_INVALID_HANDLE;
02273                 return CAC_FAILURE;
02274         }
02275 
02276         ZERO_STRUCT( ctr );
02277 
02278         init_samr_group_info2( &ctr.group.info2, op->in.new_name );
02279         ctr.switch_value1 = 2;
02280 
02281         hnd->status =
02282                 rpccli_samr_set_groupinfo( pipe_hnd, mem_ctx,
02283                                            op->in.group_hnd, &ctr );
02284 
02285         if ( !NT_STATUS_IS_OK( hnd->status ) )
02286                 return CAC_FAILURE;
02287 
02288         return CAC_SUCCESS;
02289 }

int cac_SamGetAliasInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetAliasInfo op 
)

Retrieves information about an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2291 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamGetAliasInfo::alias_hndcac_GetPipe()cac_MakeAliasInfo()CacServerHandleInternal::ctxSamGetAliasInfo::inSamGetAliasInfo::infoSamGetAliasInfo::outCacServerHandleInternal::pipesrpccli_samr_query_alias_info()_CACSERVERHANDLE::status.

02293 {
02294         struct rpc_pipe_client *pipe_hnd = NULL;
02295 
02296         ALIAS_INFO_CTR ctr;
02297 
02298         if ( !hnd )
02299                 return CAC_FAILURE;
02300 
02301         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02302                 hnd->status = NT_STATUS_INVALID_HANDLE;
02303                 return CAC_FAILURE;
02304         }
02305 
02306         if ( !op->in.alias_hnd || !mem_ctx ) {
02307                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02308                 return CAC_FAILURE;
02309         }
02310 
02311         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02312         if ( !pipe_hnd ) {
02313                 hnd->status = NT_STATUS_INVALID_HANDLE;
02314                 return CAC_FAILURE;
02315         }
02316 
02317         /*get a GROUP_INFO_1 structure */
02318         hnd->status =
02319                 rpccli_samr_query_alias_info( pipe_hnd, mem_ctx,
02320                                               op->in.alias_hnd, 1, &ctr );
02321 
02322         if ( !NT_STATUS_IS_OK( hnd->status ) )
02323                 return CAC_FAILURE;
02324 
02325         op->out.info = cac_MakeAliasInfo( mem_ctx, ctr );
02326         if ( !op->out.info ) {
02327                 hnd->status = NT_STATUS_NO_MEMORY;
02328                 return CAC_FAILURE;
02329         }
02330 
02331         return CAC_SUCCESS;
02332 
02333 }

int cac_SamSetAliasInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamSetAliasInfo op 
)

Sets information about an alias.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code

CAC_SUCCESS The operation completed successfully

cac_samr.c2335 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamSetAliasInfo::alias_hndcac_GetPipe()cac_MakeAliasInfoCtr()CacServerHandleInternal::ctxSamSetAliasInfo::inSamSetAliasInfo::infoCacServerHandleInternal::pipesrpccli_samr_set_aliasinfo()_CACSERVERHANDLE::status.

02337 {
02338         struct rpc_pipe_client *pipe_hnd = NULL;
02339 
02340         ALIAS_INFO_CTR *ctr = NULL;
02341 
02342         if ( !hnd )
02343                 return CAC_FAILURE;
02344 
02345         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02346                 hnd->status = NT_STATUS_INVALID_HANDLE;
02347                 return CAC_FAILURE;
02348         }
02349 
02350         if ( !op->in.alias_hnd || !op->in.info || !mem_ctx ) {
02351                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02352                 return CAC_FAILURE;
02353         }
02354 
02355         ctr = cac_MakeAliasInfoCtr( mem_ctx, op->in.info );
02356         if ( !ctr ) {
02357                 hnd->status = NT_STATUS_NO_MEMORY;
02358                 return CAC_FAILURE;
02359         }
02360 
02361         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02362         if ( !pipe_hnd ) {
02363                 hnd->status = NT_STATUS_INVALID_HANDLE;
02364                 return CAC_FAILURE;
02365         }
02366 
02367         hnd->status =
02368                 rpccli_samr_set_aliasinfo( pipe_hnd, mem_ctx,
02369                                            op->in.alias_hnd, ctr );
02370 
02371         if ( !NT_STATUS_IS_OK( hnd->status ) )
02372                 return CAC_FAILURE;
02373 
02374         return CAC_SUCCESS;
02375 }

int cac_SamGetDomainInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetDomainInfo op 
)

Gets domain information in the form of a CacDomainInfo structure.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
SamGetDomainInfoCtr()
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

CAC_PARTIAL_SUCCESS - This function makes 3 rpc calls, if one or two fail and the rest succeed, not all fields in the CacDomainInfo structure will be filled

cac_samr.c2377 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()cac_MakeDomainInfo()CacServerHandleInternal::ctxSamGetDomainInfo::dom_hndSamGetDomainInfo::insam_unknown_ctr_info::inf1sam_unknown_ctr_info::inf12sam_unknown_ctr_info::inf2sam_unknown_ctr_info::infoSamGetDomainInfo::infoSamGetDomainInfo::outCacServerHandleInternal::pipesrpccli_samr_query_dom_info()_CACSERVERHANDLE::status.

02379 {
02380         struct rpc_pipe_client *pipe_hnd = NULL;
02381 
02382         SAM_UNK_CTR ctr;
02383         SAM_UNK_INFO_1 info1;
02384         SAM_UNK_INFO_2 info2;
02385         SAM_UNK_INFO_12 info12;
02386 
02387         /*use this to keep track of a failed call */
02388         NTSTATUS status_buf = NT_STATUS_OK;
02389 
02390         uint16 fail_count = 0;
02391 
02392 
02393         if ( !hnd )
02394                 return CAC_FAILURE;
02395 
02396         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02397                 hnd->status = NT_STATUS_INVALID_HANDLE;
02398                 return CAC_FAILURE;
02399         }
02400 
02401         if ( !op->in.dom_hnd || !mem_ctx ) {
02402                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02403                 return CAC_FAILURE;
02404         }
02405 
02406         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02407         if ( !pipe_hnd ) {
02408                 hnd->status = NT_STATUS_INVALID_HANDLE;
02409                 return CAC_FAILURE;
02410         }
02411 
02412         /*first try with info 1 */
02413         hnd->status =
02414                 rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
02415                                             1, &ctr );
02416 
02417         if ( NT_STATUS_IS_OK( hnd->status ) ) {
02418                 /*then we buffer the SAM_UNK_INFO_1 structure */
02419                 info1 = ctr.info.inf1;
02420         } else {
02421                 /*then the call failed, store the status and ZERO out the info structure */
02422                 ZERO_STRUCT( info1 );
02423                 status_buf = hnd->status;
02424                 fail_count++;
02425         }
02426 
02427         /*try again for the next one */
02428         hnd->status =
02429                 rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
02430                                             2, &ctr );
02431 
02432         if ( NT_STATUS_IS_OK( hnd->status ) ) {
02433                 /*store the info */
02434                 info2 = ctr.info.inf2;
02435         } else {
02436                 /*ZERO out the structure and store the bad status */
02437                 ZERO_STRUCT( info2 );
02438                 status_buf = hnd->status;
02439                 fail_count++;
02440         }
02441 
02442         /*once more */
02443         hnd->status =
02444                 rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
02445                                             12, &ctr );
02446 
02447         if ( NT_STATUS_IS_OK( hnd->status ) ) {
02448                 info12 = ctr.info.inf12;
02449         } else {
02450                 ZERO_STRUCT( info12 );
02451                 status_buf = hnd->status;
02452                 fail_count++;
02453         }
02454 
02455         /*return failure if all 3 calls failed */
02456         if ( fail_count == 3 )
02457                 return CAC_FAILURE;
02458 
02459         op->out.info = cac_MakeDomainInfo( mem_ctx, &info1, &info2, &info12 );
02460 
02461         if ( !op->out.info ) {
02462                 hnd->status = NT_STATUS_NO_MEMORY;
02463                 return CAC_FAILURE;
02464         }
02465 
02466         if ( fail_count > 0 ) {
02467                 hnd->status = status_buf;
02468                 return CAC_PARTIAL_SUCCESS;
02469         }
02470 
02471         return CAC_SUCCESS;
02472 }

int cac_SamGetDomainInfoCtr ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetDomainInfoCtr op 
)

Gets domain information in the form of a SAM_UNK_CTR structure.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
参照:
SamGetDomainInfo()
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

cac_samr.c2474 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamGetDomainInfoCtr::dom_hndSamGetDomainInfoCtr::inSamGetDomainInfoCtr::infoSamGetDomainInfoCtr::info_classSamGetDomainInfoCtr::outCacServerHandleInternal::pipesrpccli_samr_query_dom_info()_CACSERVERHANDLE::status.

02476 {
02477         struct rpc_pipe_client *pipe_hnd = NULL;
02478 
02479         SAM_UNK_CTR *ctr_out;
02480 
02481         if ( !hnd )
02482                 return CAC_FAILURE;
02483 
02484         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02485                 hnd->status = NT_STATUS_INVALID_HANDLE;
02486                 return CAC_FAILURE;
02487         }
02488 
02489         if ( !op->in.dom_hnd || op->in.info_class == 0 || !mem_ctx ) {
02490                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02491                 return CAC_FAILURE;
02492         }
02493 
02494         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02495         if ( !pipe_hnd ) {
02496                 hnd->status = NT_STATUS_INVALID_HANDLE;
02497                 return CAC_FAILURE;
02498         }
02499 
02500         ctr_out = talloc( mem_ctx, SAM_UNK_CTR );
02501         if ( !ctr_out ) {
02502                 hnd->status = NT_STATUS_NO_MEMORY;
02503                 return CAC_FAILURE;
02504         }
02505 
02506         hnd->status =
02507                 rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd,
02508                                             op->in.info_class, ctr_out );
02509 
02510         if ( !NT_STATUS_IS_OK( hnd->status ) )
02511                 return CAC_FAILURE;
02512 
02513         op->out.info = ctr_out;
02514 
02515         return CAC_SUCCESS;
02516 }

int cac_SamGetDisplayInfo ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetDisplayInfo op 
)

Gets dislpay information using a SAM_DISPINFO_CTR.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

cac_samr.c2518 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()SamGetDisplayInfo::ctrCacServerHandleInternal::ctxSamGetDisplayInfo::dom_hndSamGetDisplayInfo::doneget_query_dispinfo_params()SamGetDisplayInfo::inSamGetDisplayInfo::info_classSamGetDisplayInfo::loop_countSamGetDisplayInfo::max_entriesSamGetDisplayInfo::max_sizeSamGetDisplayInfo::num_entriesSamGetDisplayInfo::outCacServerHandleInternal::pipesSamGetDisplayInfo::resume_idxrpccli_samr_query_dispinfo()_CACSERVERHANDLE::status.

02520 {
02521         struct rpc_pipe_client *pipe_hnd = NULL;
02522 
02523         SAM_DISPINFO_CTR ctr_out;
02524 
02525         uint32 max_entries_buf = 0;
02526         uint32 max_size_buf = 0;
02527 
02528         uint32 resume_idx_out;
02529         uint32 num_entries_out;
02530 
02531         if ( !hnd )
02532                 return CAC_FAILURE;
02533 
02534         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02535                 hnd->status = NT_STATUS_INVALID_HANDLE;
02536                 return CAC_FAILURE;
02537         }
02538 
02539         if ( !op->in.dom_hnd || op->in.info_class == 0 || !mem_ctx ) {
02540                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02541                 return CAC_FAILURE;
02542         }
02543 
02544         if ( op->out.done == True )     /*this is done so we can use the function as a loop condition */
02545                 return CAC_FAILURE;
02546 
02547         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02548         if ( !pipe_hnd ) {
02549                 hnd->status = NT_STATUS_INVALID_HANDLE;
02550                 return CAC_FAILURE;
02551         }
02552 
02553         if ( op->in.max_entries == 0 || op->in.max_size == 0 ) {
02554                 get_query_dispinfo_params( op->out.loop_count,
02555                                            &max_entries_buf, &max_size_buf );
02556         } else {
02557                 max_entries_buf = op->in.max_entries;
02558                 max_size_buf = op->in.max_size;
02559         }
02560 
02561         resume_idx_out = op->out.resume_idx;
02562 
02563         hnd->status =
02564                 rpccli_samr_query_dispinfo( pipe_hnd, mem_ctx, op->in.dom_hnd,
02565                                             &resume_idx_out,
02566                                             op->in.info_class,
02567                                             &num_entries_out, max_entries_buf,
02568                                             max_size_buf, &ctr_out );
02569 
02570         if ( !NT_STATUS_IS_OK( hnd->status )
02571              && !NT_STATUS_EQUAL( hnd->status, STATUS_MORE_ENTRIES ) ) {
02572                 /*be defensive, maybe they'll call again without zeroing the struct */
02573                 op->out.loop_count = 0;
02574                 op->out.resume_idx = 0;
02575                 return CAC_FAILURE;
02576         }
02577 
02578         if ( NT_STATUS_IS_OK( hnd->status ) ) {
02579                 /*we want to quit once the function is called next. so it can be used in a loop */
02580                 op->out.done = True;
02581         }
02582 
02583         op->out.resume_idx = resume_idx_out;
02584         op->out.num_entries = num_entries_out;
02585         op->out.ctr = ctr_out;
02586         op->out.loop_count++;
02587 
02588         return CAC_SUCCESS;
02589 }

int cac_SamLookupDomain ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamLookupDomain op 
)

Looks up a Domain SID given it's name.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

cac_samr.c2591 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamLookupDomain::inSamLookupDomain::nameSamLookupDomain::outCacServerHandleInternal::pipesrpccli_samr_lookup_domain()SamLookupDomain::samSamLookupDomain::sid_CACSERVERHANDLE::status.

参照元 cac_SamOpenDomain().

02593 {
02594         struct rpc_pipe_client *pipe_hnd = NULL;
02595 
02596         DOM_SID *sid_out = NULL;
02597 
02598         if ( !hnd )
02599                 return CAC_FAILURE;
02600 
02601         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02602                 hnd->status = NT_STATUS_INVALID_HANDLE;
02603                 return CAC_FAILURE;
02604         }
02605 
02606         if ( !op->in.sam || !op->in.name || !mem_ctx ) {
02607                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02608                 return CAC_FAILURE;
02609         }
02610 
02611         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02612         if ( !pipe_hnd ) {
02613                 hnd->status = NT_STATUS_INVALID_HANDLE;
02614                 return CAC_FAILURE;
02615         }
02616 
02617         sid_out = talloc( mem_ctx, DOM_SID );
02618         if ( !sid_out ) {
02619                 hnd->status = NT_STATUS_NO_MEMORY;
02620                 return CAC_FAILURE;
02621         }
02622 
02623         hnd->status =
02624                 rpccli_samr_lookup_domain( pipe_hnd, mem_ctx, op->in.sam,
02625                                            op->in.name, sid_out );
02626 
02627         if ( !NT_STATUS_IS_OK( hnd->status ) )
02628                 return CAC_FAILURE;
02629 
02630         op->out.sid = sid_out;
02631 
02632         return CAC_SUCCESS;
02633 }

int cac_SamGetSecurityObject ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamGetSecurityObject op 
)

Retrievies Security descriptor information for a SAM/Domain/user

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized parameters
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

cac_samr.c2635 行で定義されています。

参照先 _CACSERVERHANDLE::_internalcac_GetPipe()CacServerHandleInternal::ctxSamGetSecurityObject::inSamGetSecurityObject::outCacServerHandleInternal::pipesSamGetSecurityObject::polrpccli_samr_query_sec_obj()SamGetSecurityObject::sec_CACSERVERHANDLE::status.

02637 {
02638         struct rpc_pipe_client *pipe_hnd = NULL;
02639 
02640         /*this number taken from rpcclient/cmd_samr.c, I think it is the only supported level */
02641         uint32 sec_info = DACL_SECURITY_INFORMATION;
02642 
02643         SEC_DESC_BUF *sec_out = NULL;
02644 
02645         if ( !hnd )
02646                 return CAC_FAILURE;
02647 
02648         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02649                 hnd->status = NT_STATUS_INVALID_HANDLE;
02650                 return CAC_FAILURE;
02651         }
02652 
02653         if ( !op->in.pol || !mem_ctx ) {
02654                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02655                 return CAC_FAILURE;
02656         }
02657 
02658         pipe_hnd = cac_GetPipe( hnd, PI_SAMR );
02659         if ( !pipe_hnd ) {
02660                 hnd->status = NT_STATUS_INVALID_HANDLE;
02661                 return CAC_FAILURE;
02662         }
02663 
02664         hnd->status =
02665                 rpccli_samr_query_sec_obj( pipe_hnd, mem_ctx, op->in.pol,
02666                                            sec_info, mem_ctx, &sec_out );
02667 
02668         if ( !NT_STATUS_IS_OK( hnd->status ) )
02669                 return CAC_FAILURE;
02670 
02671         op->out.sec = sec_out;
02672 
02673         return CAC_SUCCESS;
02674 }

int cac_SamFlush ( CacServerHandle hnd,
TALLOC_CTX mem_ctx,
struct SamFlush op 
)

Closes the domain handle, then re-opens it - effectively flushing any changes made.

WARNING: if this fails you will no longer have an open handle to the domain SAM.

引数:
hnd Initialized and connected server handle
mem_ctx Context for memory allocation
op Initialized Parameters
戻り値:
CAC_FAILURE - the operation was not successful hnd->status is set appropriately

CAC_SUCCESS - the operation was successful

cac_samr.c2676 行で定義されています。

参照先 _CACSERVERHANDLE::_internalSamOpenDomain::accessSamFlush::accesscac_SamClose()cac_SamOpenDomain()CacServerHandleInternal::ctxSamFlush::dom_hndSamOpenDomain::dom_hndSamFlush::inSamOpenDomain::inSamOpenDomain::outCacServerHandleInternal::pipesSamOpenDomain::sidSamFlush::sid_CACSERVERHANDLE::status.

02678 {
02679         struct SamOpenDomain od;
02680 
02681         if ( !hnd )
02682                 return CAC_FAILURE;
02683 
02684         if ( !hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR] ) {
02685                 hnd->status = NT_STATUS_INVALID_HANDLE;
02686                 return CAC_FAILURE;
02687         }
02688 
02689         if ( !op || !op->in.dom_hnd || !mem_ctx ) {
02690                 hnd->status = NT_STATUS_INVALID_PARAMETER;
02691                 return CAC_FAILURE;
02692         }
02693 
02694         if ( !cac_SamClose( hnd, mem_ctx, op->in.dom_hnd ) )
02695                 return CAC_FAILURE;
02696 
02697         ZERO_STRUCT( od );
02698         od.in.access =
02699                 ( op->in.access ) ? op->in.access : MAXIMUM_ALLOWED_ACCESS;
02700         od.in.sid = op->in.sid;
02701 
02702         if ( !cac_SamOpenDomain( hnd, mem_ctx, &od ) )
02703                 return CAC_FAILURE;
02704 
02705         /*this function does not use an output parameter to make it as convenient as possible to use */
02706         *op->in.dom_hnd = *od.out.dom_hnd;
02707 
02708         TALLOC_FREE( od.out.dom_hnd );
02709 
02710         return CAC_SUCCESS;
02711 }


Sambaに対してSat Aug 29 21:24:39 2009に生成されました。  doxygen 1.4.7