svn commit: samba r9544 - in
branches/SOC/SAMBA_3_0/source/libmsrpc/test: . sam
skel at samba.org
skel at samba.org
Tue Aug 23 21:03:45 GMT 2005
Author: skel
Date: 2005-08-23 21:03:44 +0000 (Tue, 23 Aug 2005)
New Revision: 9544
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9544
Log:
added dominfo to test cac_SamGetDomainInfo()
Added:
branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/dominfo.c
Modified:
branches/SOC/SAMBA_3_0/source/libmsrpc/test/Makefile
branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/adduser.c
branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.c
branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.h
Changeset:
Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/test/Makefile
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/Makefile 2005-08-23 20:53:39 UTC (rev 9543)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/Makefile 2005-08-23 21:03:44 UTC (rev 9544)
@@ -9,7 +9,8 @@
LDFLAGS=-L. -L../../bin/
LIBS=../../bin/libmsrpc.so
-TESTS= lsapol lsaq lsaenum lsaenumprivs regkeycreate regvalenum shutdown regsetval regqueryval regdelete savekey security regkeyenum adduser samenum samlookup samgroup enable disable
+TESTS= lsapol lsaq lsaenum lsaenumprivs regkeycreate regvalenum shutdown regsetval regqueryval regdelete savekey security regkeyenum adduser \
+ samenum samlookup samgroup enable disable dominfo
all: $(TESTS)
@@ -94,5 +95,8 @@
samuser: sam/samuser.o test_util.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
+dominfo: sam/dominfo.o test_util.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
+
clean:
rm -f $(TESTS) *.o lsa/*.o reg/*.o sam/*.o
Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/adduser.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/adduser.c 2005-08-23 20:53:39 UTC (rev 9543)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/adduser.c 2005-08-23 21:03:44 UTC (rev 9544)
@@ -35,7 +35,7 @@
goto done;
}
- struct SamCreateDomainUser cdu;
+ struct SamCreateUser cdu;
ZERO_STRUCT(cdu);
printf("Enter account name: ");
@@ -45,7 +45,7 @@
cdu.in.username = talloc_strdup(mem_ctx, tmp);
cdu.in.acb = ACB_NORMAL;
- if(!cac_SamCreateDomainUser(hnd, mem_ctx, &cdu)) {
+ if(!cac_SamCreateUser(hnd, mem_ctx, &cdu)) {
fprintf(stderr, "Could not create user %s. Error: %s\n", cdu.in.username, nt_errstr(hnd->status));
}
Added: branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/dominfo.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/dominfo.c 2005-08-23 20:53:39 UTC (rev 9543)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/sam/dominfo.c 2005-08-23 21:03:44 UTC (rev 9544)
@@ -0,0 +1,55 @@
+/*gets domain info and prints it out*/
+
+#include "libmsrpc.h"
+#include "test_util.h"
+
+int main(int argc, char **argv) {
+ CacServerHandle *hnd = NULL;
+ TALLOC_CTX *mem_ctx = NULL;
+
+ mem_ctx = talloc_init("cac_dominfo");
+
+ hnd = cac_NewServerHandle();
+
+ cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
+
+ cac_parse_cmd_line(argc, argv, hnd);
+
+ if(!cac_Connect(hnd, NULL)) {
+ fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
+ exit(-1);
+ }
+
+ struct SamOpenDomain sod;
+ ZERO_STRUCT(sod);
+
+ sod.in.access = MAXIMUM_ALLOWED_ACCESS;
+
+ if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
+ fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
+ goto done;
+ }
+
+ struct SamGetDomainInfo gdi;
+ ZERO_STRUCT(gdi);
+
+ gdi.in.domain_hnd = sod.out.pol;
+
+ if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) {
+ fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status));
+ goto done;
+ }
+
+ printf("Got domain info:\n");
+ print_cac_domain_info(gdi.out.info);
+
+done:
+ cac_SamClose(hnd, mem_ctx, sod.out.pol);
+
+ cac_FreeHandle(hnd);
+
+ talloc_destroy(mem_ctx);
+
+ return 0;
+}
+
Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.c 2005-08-23 20:53:39 UTC (rev 9543)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.c 2005-08-23 21:03:44 UTC (rev 9544)
@@ -339,3 +339,47 @@
info->description = talloc_strdup(mem_ctx, tmp);
}
+char *srv_role_str(uint32 role) {
+ switch(role) {
+ case ROLE_STANDALONE:
+ return "STANDALONE";
+ break;
+ case ROLE_DOMAIN_MEMBER:
+ return "DOMAIN_MEMBER";
+ break;
+ case ROLE_DOMAIN_BDC:
+ return "DOMAIN_BDC";
+ break;
+ case ROLE_DOMAIN_PDC:
+ return "DOMAIN_PDC";
+ break;
+ }
+
+ return "Invalid role!\n";
+}
+
+char *cactime_str(CacTime ctime, fstring tmp) {
+
+ snprintf(tmp, sizeof(fstring), "%u Days, %u Hours, %u Minutes, %u Seconds", ctime.days, ctime.hours, ctime.minutes, ctime.seconds);
+
+ return tmp;
+}
+
+void print_cac_domain_info(CacDomainInfo *info) {
+ fstring tmp;
+
+ printf(" Server Role : %s\n", srv_role_str(info->server_role));
+ printf(" Num Users : %d\n", info->num_users);
+ printf(" Num Domain Groups: %d\n", info->num_domain_groups);
+ printf(" Num Local Groups : %d\n", info->num_local_groups);
+ printf(" Comment : %s\n", info->comment);
+ printf(" Domain Name : %s\n", info->domain_name);
+ printf(" Server Name : %s\n", info->server_name);
+ printf(" Min. Pass. Length: %d\n", info->min_pass_length);
+ printf(" Password History : %d\n", info->pass_history);
+ printf("\n");
+ printf(" Passwords Expire In : %s\n", cactime_str(info->expire, tmp));
+ printf(" Passwords Can Change in: %s\n", cactime_str(info->min_pass_age, tmp));
+ printf(" Lockouts last : %s\n", cactime_str(info->lockout_duration, tmp));
+ printf(" Allowed Bad Attempts : %d\n", info->num_bad_attempts);
+}
Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.h
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.h 2005-08-23 20:53:39 UTC (rev 9543)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/test_util.h 2005-08-23 21:03:44 UTC (rev 9544)
@@ -23,5 +23,6 @@
void edit_cac_user_info(TALLOC_CTX *mem_ctx, CacUserInfo *info);
void print_cac_group_info(CacGroupInfo *info);
void edit_cac_group_info(TALLOC_CTX *mem_ctx, CacGroupInfo *info);
+void print_cac_domain_info(CacDomainInfo *info);
#endif /*TEST_UTIL_H*/
More information about the samba-cvs
mailing list