2 * Unix SMB/CIFS implementation.
3 * NetUserModalsGet query
4 * Copyright (C) Guenther Deschner 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <sys/types.h>
30 int main(int argc
, const char **argv
)
32 NET_API_STATUS status
;
33 struct libnetapi_ctx
*ctx
= NULL
;
34 const char *hostname
= NULL
;
35 uint8_t *buffer
= NULL
;
39 struct USER_MODALS_INFO_0
*u0
;
40 struct USER_MODALS_INFO_1
*u1
;
41 struct USER_MODALS_INFO_2
*u2
;
42 struct USER_MODALS_INFO_3
*u3
;
47 struct poptOption long_options
[] = {
49 POPT_COMMON_LIBNETAPI_EXAMPLES
53 status
= libnetapi_init(&ctx
);
58 pc
= poptGetContext("user_modalsget", argc
, argv
, long_options
, 0);
60 poptSetOtherOptionHelp(pc
, "hostname level");
61 while((opt
= poptGetNextOpt(pc
)) != -1) {
64 if (!poptPeekArg(pc
)) {
65 poptPrintHelp(pc
, stderr
, 0);
68 hostname
= poptGetArg(pc
);
70 if (poptPeekArg(pc
)) {
71 level
= atoi(poptGetArg(pc
));
74 /* NetUserModalsGet */
76 status
= NetUserModalsGet(hostname
,
80 printf("NetUserModalsGet failed with: %s\n",
81 libnetapi_get_error_string(ctx
, status
));
87 u0
= (struct USER_MODALS_INFO_0
*)buffer
;
88 printf("min passwd len: %d character\n",
89 u0
->usrmod0_min_passwd_len
);
90 printf("max passwd age: %d (days)\n",
91 u0
->usrmod0_max_passwd_age
/86400);
92 printf("min passwd age: %d (days)\n",
93 u0
->usrmod0_min_passwd_age
/86400);
94 printf("force logoff: %d (seconds)\n",
95 u0
->usrmod0_force_logoff
);
96 printf("password history length: %d entries\n",
97 u0
->usrmod0_password_hist_len
);
100 u1
= (struct USER_MODALS_INFO_1
*)buffer
;
101 printf("role: %d\n", u1
->usrmod1_role
);
102 printf("primary: %s\n", u1
->usrmod1_primary
);
105 u2
= (struct USER_MODALS_INFO_2
*)buffer
;
106 printf("domain name: %s\n", u2
->usrmod2_domain_name
);
107 if (ConvertSidToStringSid(u2
->usrmod2_domain_id
,
109 printf("domain sid: %s\n", sid_str
);
114 u3
= (struct USER_MODALS_INFO_3
*)buffer
;
115 printf("lockout duration: %d (seconds)\n",
116 u3
->usrmod3_lockout_duration
);
117 printf("lockout observation window: %d (seconds)\n",
118 u3
->usrmod3_lockout_observation_window
);
119 printf("lockout threshold: %d entries\n",
120 u3
->usrmod3_lockout_threshold
);