2 * Unix SMB/CIFS implementation.
3 * SMB parameters and setup
4 * Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
5 * Copyright (C) Benny Holmgren 1998 <bigfoot@astrakan.hgs.se>
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998.
7 * Copyright (C) Toomas Soome <tsoome@ut.ee> 2001
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 675
21 * Mass Ave, Cambridge, MA 02139, USA.
26 #ifdef WITH_NISPLUS_SAM
28 #ifdef BROKEN_NISPLUS_INCLUDE_FILES
31 * The following lines are needed due to buggy include files
32 * in Solaris 2.6 which define GROUP in both /usr/include/sys/acl.h and
33 * also in /usr/include/rpcsvc/nis.h. The definitions conflict. JRA.
34 * Also GROUP_OBJ is defined as 0x4 in /usr/include/sys/acl.h and as
35 * an enum in /usr/include/rpcsvc/nis.h.
42 #if defined(GROUP_OBJ)
48 #include <rpcsvc/nis.h>
50 extern int DEBUGLEVEL;
58 static struct nisp_enum_info global_nisp_ent;
59 static SIG_ATOMIC_T gotalarm;
61 /***************************************************************
63 the fields for the NIS+ table, generated from mknissmbpwtbl.sh, are:
92 ****************************************************************/
96 #define NPF_USER_RID 2
97 #define NPF_SMB_GRPID 3
98 #define NPF_GROUP_RID 4
102 #define NPF_LOGON_T 8
103 #define NPF_LOGOFF_T 9
104 #define NPF_KICK_T 10
105 #define NPF_PWDLSET_T 11
106 #define NPF_PWDCCHG_T 12
107 #define NPF_PWDMCHG_T 13
108 #define NPF_FULL_NAME 14
109 #define NPF_HOME_DIR 15
110 #define NPF_DIR_DRIVE 16
111 #define NPF_LOGON_SCRIPT 17
112 #define NPF_PROFILE_PATH 18
113 #define NPF_ACCT_DESC 19
114 #define NPF_WORKSTATIONS 20
118 /*******************************************************************
119 Converts NT user RID to a UNIX uid.
120 ********************************************************************/
122 static uid_t pdb_user_rid_to_uid(uint32 user_rid)
124 return (uid_t)(((user_rid & (~USER_RID_TYPE))- 1000)/RID_MULTIPLIER);
127 /*******************************************************************
128 converts UNIX uid to an NT User RID.
129 ********************************************************************/
131 static uint32 pdb_uid_to_user_rid(uid_t uid)
133 return (((((uint32)uid)*RID_MULTIPLIER) + 1000) | USER_RID_TYPE);
136 /***************************************************************
137 Signal function to tell us we timed out.
138 ****************************************************************/
139 static void gotalarm_sig(void)
144 /***************************************************************
145 make_nisname_from_user_rid
146 ****************************************************************/
147 static char *make_nisname_from_user_rid(uint32 rid, char *pfile)
149 static pstring nisname;
151 safe_strcpy(nisname, "[user_rid=", sizeof(nisname)-1);
152 slprintf(nisname, sizeof(nisname)-1, "%s%d", nisname, rid);
153 safe_strcat(nisname, "],", sizeof(nisname)-strlen(nisname)-1);
154 safe_strcat(nisname, pfile, sizeof(nisname)-strlen(nisname)-1);
159 /***************************************************************
160 make_nisname_from_uid
161 ****************************************************************/
162 static char *make_nisname_from_uid(int uid, char *pfile)
164 static pstring nisname;
166 safe_strcpy(nisname, "[uid=", sizeof(nisname)-1);
167 slprintf(nisname, sizeof(nisname)-1, "%s%d", nisname, uid);
168 safe_strcat(nisname, "],", sizeof(nisname)-strlen(nisname)-1);
169 safe_strcat(nisname, pfile, sizeof(nisname)-strlen(nisname)-1);
174 /***************************************************************
175 make_nisname_from_name
176 ****************************************************************/
177 static char *make_nisname_from_name(const char *user_name, char *pfile)
179 static pstring nisname;
181 safe_strcpy(nisname, "[name=", sizeof(nisname)-1);
182 safe_strcat(nisname, user_name, sizeof(nisname) - strlen(nisname) - 1);
183 safe_strcat(nisname, "],", sizeof(nisname)-strlen(nisname)-1);
184 safe_strcat(nisname, pfile, sizeof(nisname)-strlen(nisname)-1);
189 /*************************************************************************
190 gets a NIS+ attribute
191 *************************************************************************/
192 static void get_single_attribute(const nis_object *new_obj, int col,
197 if (new_obj == NULL || val == NULL) return;
199 entry_len = ENTRY_LEN(new_obj, col);
205 safe_strcpy(val, ENTRY_VAL(new_obj, col), len-1);
208 /************************************************************************
209 makes a struct sam_passwd from a NIS+ object.
210 ************************************************************************/
211 static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, const nis_object *obj)
214 pstring full_name; /* this must be translated to dos code page */
215 pstring acct_desc; /* this must be translated to dos code page */
216 pstring home_dir; /* set default value from smb.conf for user */
217 pstring home_drive; /* set default value from smb.conf for user */
218 pstring logon_script; /* set default value from smb.conf for user */
219 pstring profile_path; /* set default value from smb.conf for user */
222 unsigned char smbpwd[16];
223 unsigned char smbntpwd[16];
227 * time values. note: this code assumes 32bit time_t!
230 /* Don't change these timestamp settings without a good reason. They are
231 important for NT member server compatibility. */
233 pdb_set_logon_time(pw_buf, (time_t)0, True);
234 ptr = (uchar *)ENTRY_VAL(obj, NPF_LOGON_T);
235 if(ptr && *ptr && (StrnCaseCmp(ptr, "LNT-", 4)==0)) {
238 for(i = 0; i < 8; i++) {
239 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
243 pdb_set_logon_time(pw_buf, (time_t)strtol(ptr, NULL, 16), True);
247 pdb_set_logoff_time(pw_buf, get_time_t_max(), True);
248 ptr = (uchar *)ENTRY_VAL(obj, NPF_LOGOFF_T);
249 if(ptr && *ptr && (StrnCaseCmp(ptr, "LOT-", 4)==0)) {
252 for(i = 0; i < 8; i++) {
253 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
257 pdb_set_logoff_time(pw_buf, (time_t)strtol(ptr, NULL, 16), True);
261 pdb_set_kickoff_time(pw_buf, get_time_t_max(), True);
262 ptr = (uchar *)ENTRY_VAL(obj, NPF_KICK_T);
263 if(ptr && *ptr && (StrnCaseCmp(ptr, "KOT-", 4)==0)) {
266 for(i = 0; i < 8; i++) {
267 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
271 pdb_set_kickoff_time(pw_buf, (time_t)strtol(ptr, NULL, 16), True);
275 pdb_set_pass_last_set_time(pw_buf, (time_t)0);
276 ptr = (uchar *)ENTRY_VAL(obj, NPF_PWDLSET_T);
277 if(ptr && *ptr && (StrnCaseCmp(ptr, "LCT-", 4)==0)) {
280 for(i = 0; i < 8; i++) {
281 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
285 pdb_set_pass_last_set_time(pw_buf, (time_t)strtol(ptr, NULL, 16));
289 pdb_set_pass_can_change_time(pw_buf, (time_t)0, True);
290 ptr = (uchar *)ENTRY_VAL(obj, NPF_PWDCCHG_T);
291 if(ptr && *ptr && (StrnCaseCmp(ptr, "CCT-", 4)==0)) {
294 for(i = 0; i < 8; i++) {
295 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
299 pdb_set_pass_can_change_time(pw_buf, (time_t)strtol(ptr, NULL, 16), True);
303 pdb_set_pass_must_change_time(pw_buf, get_time_t_max(), True); /* Password never expires. */
304 ptr = (uchar *)ENTRY_VAL(obj, NPF_PWDMCHG_T);
305 if(ptr && *ptr && (StrnCaseCmp(ptr, "MCT-", 4)==0)) {
308 for(i = 0; i < 8; i++) {
309 if(ptr[i] == '\0' || !isxdigit(ptr[i]))
313 pdb_set_pass_must_change_time(pw_buf, (time_t)strtol(ptr, NULL, 16), True);
318 pdb_set_username(pw_buf, ENTRY_VAL(obj, NPF_NAME));
319 pdb_set_domain(pw_buf, lp_workgroup());
320 /* pdb_set_nt_username() -- cant set it here... */
322 get_single_attribute(obj, NPF_FULL_NAME, full_name, sizeof(pstring));
324 unix_to_dos(full_name, True);
326 pdb_set_fullname(pw_buf, full_name);
328 pdb_set_acct_ctrl(pw_buf, pdb_decode_acct_ctrl(ENTRY_VAL(obj,
331 get_single_attribute(obj, NPF_ACCT_DESC, acct_desc, sizeof(pstring));
333 unix_to_dos(acct_desc, True);
335 pdb_set_acct_desc(pw_buf, acct_desc);
337 pdb_set_workstations(pw_buf, ENTRY_VAL(obj, NPF_WORKSTATIONS));
338 pdb_set_munged_dial(pw_buf, NULL);
340 pdb_set_uid(pw_buf, atoi(ENTRY_VAL(obj, NPF_UID)));
341 pdb_set_gid(pw_buf, atoi(ENTRY_VAL(obj, NPF_SMB_GRPID)));
342 pdb_set_user_sid_from_rid(pw_buf, atoi(ENTRY_VAL(obj, NPF_USER_RID)));
343 pdb_set_group_sid_from_rid(pw_buf, atoi(ENTRY_VAL(obj, NPF_GROUP_RID)));
345 /* values, must exist for user */
346 if( !(pdb_get_acct_ctrl(pw_buf) & ACB_WSTRUST) ) {
348 get_single_attribute(obj, NPF_HOME_DIR, home_dir, sizeof(pstring));
349 if( !(home_dir && *home_dir) ) {
350 pstrcpy(home_dir, lp_logon_home());
351 pdb_set_homedir(pw_buf, home_dir, False);
354 pdb_set_homedir(pw_buf, home_dir, True);
356 get_single_attribute(obj, NPF_DIR_DRIVE, home_drive, sizeof(pstring));
357 if( !(home_drive && *home_drive) ) {
358 pstrcpy(home_drive, lp_logon_drive());
359 pdb_set_dir_drive(pw_buf, home_drive, False);
362 pdb_set_dir_drive(pw_buf, home_drive, True);
364 get_single_attribute(obj, NPF_LOGON_SCRIPT, logon_script,
366 if( !(logon_script && *logon_script) ) {
367 pstrcpy(logon_script, lp_logon_script());
370 pdb_set_logon_script(pw_buf, logon_script, True);
372 get_single_attribute(obj, NPF_PROFILE_PATH, profile_path, sizeof(pstring));
373 if( !(profile_path && *profile_path) ) {
374 pstrcpy(profile_path, lp_logon_path());
375 pdb_set_profile_path(pw_buf, profile_path, False);
378 pdb_set_profile_path(pw_buf, profile_path, True);
383 /* lkclXXXX this is OBSERVED behaviour by NT PDCs, enforced here. */
384 pdb_set_group_sid_from_rid (pw_buf, DOMAIN_GROUP_RID_USERS);
387 /* Check the lanman password column. */
388 ptr = (char *)ENTRY_VAL(obj, NPF_LMPWD);
389 if (!pdb_set_lanman_passwd(pw_buf, NULL))
392 if (!strncasecmp(ptr, "NO PASSWORD", 11)) {
393 pdb_set_acct_ctrl(pw_buf, pdb_get_acct_ctrl(pw_buf) | ACB_PWNOTREQ);
395 if (strlen(ptr) != 32 || !pdb_gethexpwd(ptr, smbpwd)) {
396 DEBUG(0, ("malformed LM pwd entry: %s.\n",
397 pdb_get_username(pw_buf)));
400 if (!pdb_set_lanman_passwd(pw_buf, smbpwd))
404 /* Check the NT password column. */
405 ptr = ENTRY_VAL(obj, NPF_NTPWD);
406 if (!pdb_set_nt_passwd(pw_buf, NULL))
409 if (!(pdb_get_acct_ctrl(pw_buf) & ACB_PWNOTREQ) &&
410 strncasecmp(ptr, "NO PASSWORD", 11)) {
411 if (strlen(ptr) != 32 || !pdb_gethexpwd(ptr, smbntpwd)) {
412 DEBUG(0, ("malformed NT pwd entry:\
414 pdb_get_uid(pw_buf)));
417 if (!pdb_set_nt_passwd(pw_buf, smbntpwd))
421 pdb_set_unknown_3(pw_buf, 0xffffff); /* don't know */
422 pdb_set_logon_divs(pw_buf, 168); /* hours per week */
424 if( (hours_len = ENTRY_LEN(obj, NPF_HOURS)) == 21 ) {
425 memcpy(hours, ENTRY_VAL(obj, NPF_HOURS), hours_len);
427 hours_len = 21; /* 21 times 8 bits = 168 */
428 /* available at all hours */
429 memset(hours, 0xff, hours_len);
431 pdb_set_hours_len(pw_buf, hours_len);
432 pdb_set_hours(pw_buf, hours);
434 pdb_set_unknown_5(pw_buf, 0x00020000); /* don't know */
435 pdb_set_unknown_6(pw_buf, 0x000004ec); /* don't know */
440 /************************************************************************
441 makes a struct sam_passwd from a NIS+ result.
442 ************************************************************************/
443 static BOOL make_sam_from_nisresult(SAM_ACCOUNT *pw_buf, const nis_result *result)
445 if (pw_buf == NULL || result == NULL) return False;
447 if (result->status != NIS_SUCCESS && result->status != NIS_NOTFOUND)
449 DEBUG(0, ("NIS+ lookup failure: %s\n",
450 nis_sperrno(result->status)));
454 /* User not found. */
455 if (NIS_RES_NUMOBJ(result) <= 0)
457 DEBUG(10, ("user not found in NIS+\n"));
461 if (NIS_RES_NUMOBJ(result) > 1)
463 DEBUG(10, ("WARNING: Multiple entries for user in NIS+ table!\n"));
466 /* Grab the first hit. */
467 return make_sam_from_nisp_object(pw_buf, &NIS_RES_OBJECT(result)[0]);
470 /*************************************************************************
471 sets a NIS+ attribute
472 *************************************************************************/
473 static void set_single_attribute(nis_object *new_obj, int col,
474 const char *val, int len, int flags)
476 if (new_obj == NULL) return;
478 ENTRY_VAL(new_obj, col) = val;
479 ENTRY_LEN(new_obj, col) = len+1;
483 new_obj->EN_data.en_cols.en_cols_val[col].ec_flags = flags;
487 /***************************************************************
488 copy or modify nis object. this object is used to add or update
490 ****************************************************************/
491 static BOOL init_nisp_from_sam(nis_object *obj, const SAM_ACCOUNT *sampass,
495 * Fill nis_object for entry add or update.
496 * if we are updateing, we have to find out differences and set
497 * EN_MODIFIED flag. also set need_to_modify to trigger
498 * nis_modify_entry() call in pdb_update_sam_account().
502 * if (modify) get data from nis_object, compare and store if
503 * different + set EN_MODIFIED and need_to_modify
507 BOOL need_to_modify = False;
508 const char *name = pdb_get_username(sampass); /* from SAM */
509 /* these must be static or allocate and free entry columns! */
510 static fstring uid; /* from SAM */
511 static fstring user_rid; /* from SAM */
512 static fstring gid; /* from SAM */
513 static fstring group_rid; /* from SAM */
514 char *acb; /* from SAM */
515 static fstring smb_passwd; /* from SAM */
516 static fstring smb_nt_passwd; /* from SAM */
517 static fstring logon_t; /* from SAM */
518 static fstring logoff_t; /* from SAM */
519 static fstring kickoff_t; /* from SAM */
520 static fstring pwdlset_t; /* from SAM */
521 static fstring pwdlchg_t; /* from SAM */
522 static fstring pwdmchg_t; /* from SAM */
523 static fstring full_name; /* from SAM */
524 static fstring acct_desc; /* from SAM */
525 static char empty[1]; /* just an empty string */
527 slprintf(uid, sizeof(uid)-1, "%u", pdb_get_uid(sampass));
528 slprintf(user_rid, sizeof(user_rid)-1, "%u",
529 pdb_get_user_rid(sampass)? pdb_get_user_rid(sampass):
530 pdb_uid_to_user_rid(pdb_get_uid(sampass)));
531 slprintf(gid, sizeof(gid)-1, "%u", pdb_get_gid(sampass));
537 rid=pdb_get_group_rid(sampass);
540 if (get_group_map_from_gid(pdb_get_gid(sampass), &map, MAPPING_WITHOUT_PRIV)) {
541 if (!sid_peek_check_rid(get_global_sam_sid(), &map.sid, &rid))
544 rid=pdb_gid_to_group_rid(pdb_get_gid(sampass));
547 slprintf(group_rid, sizeof(group_rid)-1, "%u", rid);
550 acb = pdb_encode_acct_ctrl(pdb_get_acct_ctrl(sampass),
551 NEW_PW_FORMAT_SPACE_PADDED_LEN);
552 pdb_sethexpwd (smb_passwd, pdb_get_lanman_passwd(sampass),
553 pdb_get_acct_ctrl(sampass));
554 pdb_sethexpwd (smb_nt_passwd, pdb_get_nt_passwd(sampass),
555 pdb_get_acct_ctrl(sampass));
556 slprintf(logon_t, 13, "LNT-%08X",
557 (uint32)pdb_get_logon_time(sampass));
558 slprintf(logoff_t, 13, "LOT-%08X",
559 (uint32)pdb_get_logoff_time(sampass));
560 slprintf(kickoff_t, 13, "KOT-%08X",
561 (uint32)pdb_get_kickoff_time(sampass));
562 slprintf(pwdlset_t, 13, "LCT-%08X",
563 (uint32)pdb_get_pass_last_set_time(sampass));
564 slprintf(pwdlchg_t, 13, "CCT-%08X",
565 (uint32)pdb_get_pass_can_change_time(sampass));
566 slprintf(pwdmchg_t, 13, "MCT-%08X",
567 (uint32)pdb_get_pass_must_change_time(sampass));
568 safe_strcpy(full_name, pdb_get_fullname(sampass), sizeof(full_name)-1);
569 safe_strcpy(acct_desc, pdb_get_acct_desc(sampass), sizeof(acct_desc)-1);
573 /* Not sure what to do with these guys. -tpot */
575 dos_to_unix(full_name, True);
576 dos_to_unix(acct_desc, True);
582 if(strcmp(ENTRY_VAL(old, NPF_NAME), name))
584 need_to_modify = True;
585 set_single_attribute(obj, NPF_NAME, name, strlen(name),
591 if(pdb_get_uid(sampass) != -1) {
592 if(!ENTRY_VAL(old, NPF_UID) || strcmp(ENTRY_VAL(old, NPF_UID), uid))
594 need_to_modify = True;
595 set_single_attribute(obj, NPF_UID, uid,
596 strlen(uid), EN_MODIFIED);
601 if (pdb_get_user_rid(sampass)) {
602 if(!ENTRY_VAL(old, NPF_USER_RID) ||
603 strcmp(ENTRY_VAL(old, NPF_USER_RID), user_rid) ) {
604 need_to_modify = True;
605 set_single_attribute(obj, NPF_USER_RID, user_rid,
606 strlen(user_rid), EN_MODIFIED);
611 if (pdb_get_gid(sampass) != -1) {
612 if(!ENTRY_VAL(old, NPF_SMB_GRPID) ||
613 strcmp(ENTRY_VAL(old, NPF_SMB_GRPID), gid) ) {
614 need_to_modify = True;
615 set_single_attribute(obj, NPF_SMB_GRPID, gid,
616 strlen(gid), EN_MODIFIED);
621 if (pdb_get_group_rid(sampass)) {
622 if(!ENTRY_VAL(old, NPF_GROUP_RID) ||
623 strcmp(ENTRY_VAL(old, NPF_GROUP_RID), group_rid) ) {
624 need_to_modify = True;
625 set_single_attribute(obj, NPF_GROUP_RID, group_rid,
626 strlen(group_rid), EN_MODIFIED);
631 if (!ENTRY_VAL(old, NPF_ACB) ||
632 strcmp(ENTRY_VAL(old, NPF_ACB), acb)) {
633 need_to_modify = True;
634 set_single_attribute(obj, NPF_ACB, acb, strlen(acb), EN_MODIFIED);
638 if(!ENTRY_VAL(old, NPF_LMPWD) ||
639 strcmp(ENTRY_VAL(old, NPF_LMPWD), smb_passwd) ) {
640 need_to_modify = True;
641 set_single_attribute(obj, NPF_LMPWD, smb_passwd,
642 strlen(smb_passwd), EN_CRYPT|EN_MODIFIED);
646 if(!ENTRY_VAL(old, NPF_NTPWD) ||
647 strcmp(ENTRY_VAL(old, NPF_NTPWD), smb_nt_passwd) ) {
648 need_to_modify = True;
649 set_single_attribute(obj, NPF_NTPWD, smb_nt_passwd,
650 strlen(smb_nt_passwd), EN_CRYPT|EN_MODIFIED);
654 if( pdb_get_logon_time(sampass) &&
655 (!ENTRY_VAL(old, NPF_LOGON_T) ||
656 strcmp(ENTRY_VAL(old, NPF_LOGON_T), logon_t ))) {
657 need_to_modify = True;
658 set_single_attribute(obj, NPF_LOGON_T, logon_t,
659 strlen(logon_t), EN_MODIFIED);
663 if( pdb_get_logoff_time(sampass) &&
664 (!ENTRY_VAL(old, NPF_LOGOFF_T) ||
665 strcmp(ENTRY_VAL(old, NPF_LOGOFF_T), logoff_t))) {
666 need_to_modify = True;
667 set_single_attribute(obj, NPF_LOGOFF_T, logoff_t,
668 strlen(logoff_t), EN_MODIFIED);
672 if( pdb_get_kickoff_time(sampass) &&
673 (!ENTRY_VAL(old, NPF_KICK_T) ||
674 strcmp(ENTRY_VAL(old, NPF_KICK_T), kickoff_t))) {
675 need_to_modify = True;
676 set_single_attribute(obj, NPF_KICK_T, kickoff_t,
677 strlen(kickoff_t), EN_MODIFIED);
681 if( pdb_get_pass_last_set_time(sampass) &&
682 (!ENTRY_VAL(old, NPF_PWDLSET_T) ||
683 strcmp(ENTRY_VAL(old, NPF_PWDLSET_T), pwdlset_t))) {
684 need_to_modify = True;
685 set_single_attribute(obj, NPF_PWDLSET_T, pwdlset_t,
686 strlen(pwdlset_t), EN_MODIFIED);
690 if( pdb_get_pass_can_change_time(sampass) &&
691 (!ENTRY_VAL(old, NPF_PWDCCHG_T) ||
692 strcmp(ENTRY_VAL(old, NPF_PWDCCHG_T), pwdlchg_t))) {
693 need_to_modify = True;
694 set_single_attribute(obj, NPF_PWDCCHG_T, pwdlchg_t,
695 strlen(pwdlchg_t), EN_MODIFIED);
699 if( pdb_get_pass_must_change_time(sampass) &&
700 (!ENTRY_VAL(old, NPF_PWDMCHG_T) ||
701 strcmp(ENTRY_VAL(old, NPF_PWDMCHG_T), pwdmchg_t))) {
702 need_to_modify = True;
703 set_single_attribute(obj, NPF_PWDMCHG_T, pwdmchg_t,
704 strlen(pwdmchg_t), EN_MODIFIED);
708 /* must support set, unset and change */
709 if ( (pdb_get_fullname(sampass) &&
710 !ENTRY_VAL(old, NPF_FULL_NAME)) ||
711 (ENTRY_VAL(old, NPF_FULL_NAME) &&
712 !pdb_get_fullname(sampass)) ||
713 (ENTRY_VAL(old, NPF_FULL_NAME) &&
714 pdb_get_fullname(sampass) &&
715 strcmp( ENTRY_VAL(old, NPF_FULL_NAME), full_name ))) {
716 need_to_modify = True;
717 set_single_attribute(obj, NPF_FULL_NAME, full_name,
718 strlen(full_name), EN_MODIFIED);
722 /* must support set, unset and change */
723 if( (pdb_get_homedir(sampass) &&
724 !ENTRY_VAL(old, NPF_HOME_DIR)) ||
725 (ENTRY_VAL(old, NPF_HOME_DIR) &&
726 !pdb_get_homedir(sampass)) ||
727 (ENTRY_VAL(old, NPF_HOME_DIR) &&
728 pdb_get_homedir(sampass) &&
729 strcmp( ENTRY_VAL(old, NPF_HOME_DIR),
730 pdb_get_homedir(sampass)))) {
731 need_to_modify = True;
732 set_single_attribute(obj, NPF_HOME_DIR, pdb_get_homedir(sampass),
733 strlen(pdb_get_homedir(sampass)), EN_MODIFIED);
737 /* must support set, unset and change */
738 if( (pdb_get_dirdrive(sampass) &&
739 !ENTRY_VAL(old, NPF_DIR_DRIVE)) ||
740 (ENTRY_VAL(old, NPF_DIR_DRIVE) &&
741 !pdb_get_dirdrive(sampass)) ||
742 (ENTRY_VAL(old, NPF_DIR_DRIVE) &&
743 pdb_get_dirdrive(sampass) &&
744 strcmp( ENTRY_VAL(old, NPF_DIR_DRIVE),
745 pdb_get_dirdrive(sampass)))) {
746 need_to_modify = True;
747 set_single_attribute(obj, NPF_DIR_DRIVE, pdb_get_dirdrive(sampass),
748 strlen(pdb_get_dirdrive(sampass)), EN_MODIFIED);
752 /* must support set, unset and change */
753 if( (pdb_get_logon_script(sampass) &&
754 !ENTRY_VAL(old, NPF_LOGON_SCRIPT) ||
755 (ENTRY_VAL(old, NPF_LOGON_SCRIPT) &&
756 !pdb_get_logon_script(sampass)) ||
757 ( ENTRY_VAL(old, NPF_LOGON_SCRIPT) &&
758 pdb_get_logon_script(sampass) &&
759 strcmp( ENTRY_VAL(old, NPF_LOGON_SCRIPT),
760 pdb_get_logon_script(sampass))))) {
761 need_to_modify = True;
762 set_single_attribute(obj, NPF_LOGON_SCRIPT,
763 pdb_get_logon_script(sampass),
764 strlen(pdb_get_logon_script(sampass)),
769 /* must support set, unset and change */
770 if( (pdb_get_profile_path(sampass) &&
771 !ENTRY_VAL(old, NPF_PROFILE_PATH)) ||
772 (ENTRY_VAL(old, NPF_PROFILE_PATH) &&
773 !pdb_get_profile_path(sampass)) ||
774 (ENTRY_VAL(old, NPF_PROFILE_PATH) &&
775 pdb_get_profile_path(sampass) &&
776 strcmp( ENTRY_VAL(old, NPF_PROFILE_PATH),
777 pdb_get_profile_path(sampass) ) )) {
778 need_to_modify = True;
779 set_single_attribute(obj, NPF_PROFILE_PATH,
780 pdb_get_profile_path(sampass),
781 strlen(pdb_get_profile_path(sampass)),
786 /* must support set, unset and change */
787 if( (pdb_get_acct_desc(sampass) &&
788 !ENTRY_VAL(old, NPF_ACCT_DESC)) ||
789 (ENTRY_VAL(old, NPF_ACCT_DESC) &&
790 !pdb_get_acct_desc(sampass)) ||
791 (ENTRY_VAL(old, NPF_ACCT_DESC) &&
792 pdb_get_acct_desc(sampass) &&
793 strcmp( ENTRY_VAL(old, NPF_ACCT_DESC), acct_desc ) )) {
794 need_to_modify = True;
795 set_single_attribute(obj, NPF_ACCT_DESC, acct_desc,
796 strlen(acct_desc), EN_MODIFIED);
800 /* must support set, unset and change */
801 if ( (pdb_get_workstations(sampass) &&
802 !ENTRY_VAL(old, NPF_WORKSTATIONS) ) ||
803 (ENTRY_VAL(old, NPF_WORKSTATIONS) &&
804 !pdb_get_workstations(sampass)) ||
805 (ENTRY_VAL(old, NPF_WORKSTATIONS) &&
806 pdb_get_workstations(sampass)) &&
807 strcmp( ENTRY_VAL(old, NPF_WORKSTATIONS),
808 pdb_get_workstations(sampass))) {
809 need_to_modify = True;
810 set_single_attribute(obj, NPF_WORKSTATIONS,
811 pdb_get_workstations(sampass),
812 strlen(pdb_get_workstations(sampass)),
817 if ((pdb_get_hours_len(sampass) != ENTRY_LEN(old, NPF_HOURS)) ||
818 memcmp(pdb_get_hours(sampass), ENTRY_VAL(old, NPF_HOURS),
819 ENTRY_LEN(old, NPF_HOURS))) {
820 need_to_modify = True;
821 /* set_single_attribute will add 1 for len ... */
822 set_single_attribute(obj, NPF_HOURS, pdb_get_hours(sampass),
823 pdb_get_hours_len(sampass)-1, EN_MODIFIED);
826 const char *homedir, *dirdrive, *logon_script, *profile_path, *workstations;
828 *empty = '\0'; /* empty string */
830 set_single_attribute(obj, NPF_NAME, name, strlen(name), 0);
831 set_single_attribute(obj, NPF_UID, uid, strlen(uid), 0);
832 set_single_attribute(obj, NPF_USER_RID, user_rid,
833 strlen(user_rid), 0);
834 set_single_attribute(obj, NPF_SMB_GRPID, gid, strlen(gid), 0);
835 set_single_attribute(obj, NPF_GROUP_RID, group_rid,
836 strlen(group_rid), 0);
837 set_single_attribute(obj, NPF_ACB, acb, strlen(acb), 0);
838 set_single_attribute(obj, NPF_LMPWD, smb_passwd,
839 strlen(smb_passwd), EN_CRYPT);
840 set_single_attribute(obj, NPF_NTPWD, smb_nt_passwd,
841 strlen(smb_nt_passwd), EN_CRYPT);
842 set_single_attribute(obj, NPF_LOGON_T, logon_t,
844 set_single_attribute(obj, NPF_LOGOFF_T, logoff_t,
845 strlen(logoff_t), 0);
846 set_single_attribute(obj, NPF_KICK_T, kickoff_t,
847 strlen(kickoff_t),0);
848 set_single_attribute(obj, NPF_PWDLSET_T, pwdlset_t,
849 strlen(pwdlset_t), 0);
850 set_single_attribute(obj, NPF_PWDCCHG_T, pwdlchg_t,
851 strlen(pwdlchg_t), 0);
852 set_single_attribute(obj, NPF_PWDMCHG_T, pwdmchg_t,
853 strlen(pwdmchg_t), 0);
854 set_single_attribute(obj, NPF_FULL_NAME ,
855 full_name, strlen(full_name), 0);
857 if(!(homedir = pdb_get_homedir(sampass)))
860 set_single_attribute(obj, NPF_HOME_DIR,
861 homedir, strlen(homedir), 0);
863 if(!(dirdrive = pdb_get_dirdrive(sampass)))
866 set_single_attribute(obj, NPF_DIR_DRIVE,
867 dirdrive, strlen(dirdrive), 0);
869 if(!(logon_script = pdb_get_logon_script(sampass)))
870 logon_script = empty;
872 set_single_attribute(obj, NPF_LOGON_SCRIPT,
873 logon_script, strlen(logon_script), 0);
875 if(!(profile_path = pdb_get_profile_path(sampass)))
876 profile_path = empty;
878 set_single_attribute(obj, NPF_PROFILE_PATH,
879 profile_path, strlen(profile_path), 0);
881 set_single_attribute(obj, NPF_ACCT_DESC,
882 acct_desc, strlen(acct_desc), 0);
884 if(!(workstations = pdb_get_workstations(sampass)))
885 workstations = empty;
887 set_single_attribute(obj, NPF_WORKSTATIONS,
888 workstations, strlen(workstations), 0);
890 /* set_single_attribute will add 1 for len ... */
891 set_single_attribute(obj, NPF_HOURS,
892 pdb_get_hours(sampass),
893 pdb_get_hours_len(sampass)-1, 0);
896 return need_to_modify;
899 /***************************************************************
900 calls nis_list, returns results.
901 ****************************************************************/
902 static nis_result *nisp_get_nis_list(const char *nis_name, unsigned int flags)
908 flags = FOLLOW_LINKS|FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP;
910 for(i = 0; i<2;i++ ) {
911 alarm(60); /* hopefully ok for long searches */
912 result = nis_list(nis_name, flags,NULL,NULL);
915 CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
919 DEBUG(0,("NIS+ lookup time out\n"));
920 nis_freeresult(result);
923 if( !(flags & MASTER_ONLY) && NIS_RES_NUMOBJ(result) <= 0 ) {
924 /* nis replicas are not in sync perhaps?
925 * this can happen, if account was just added.
927 DEBUG(10,("will try master only\n"));
928 nis_freeresult(result);
929 flags |= MASTER_ONLY;
936 /***************************************************************
937 Start to enumerate the nisplus passwd list.
938 ****************************************************************/
939 BOOL pdb_setsampwent(BOOL update)
941 char *sp, * p = lp_smb_passwd_file();
944 if( (sp = strrchr( p, '/' )) )
945 safe_strcpy(pfiletmp, sp+1, sizeof(pfiletmp)-1);
947 safe_strcpy(pfiletmp, p, sizeof(pfiletmp)-1);
948 safe_strcat(pfiletmp, ".org_dir", sizeof(pfiletmp)-strlen(pfiletmp)-1);
950 pdb_endsampwent(); /* just in case */
951 global_nisp_ent.result = nisp_get_nis_list( pfiletmp, 0 );
952 global_nisp_ent.enum_entry = 0;
953 return global_nisp_ent.result != NULL ? True : False;
956 /***************************************************************
957 End enumeration of the nisplus passwd list.
958 ****************************************************************/
959 void pdb_endsampwent(void)
961 if( global_nisp_ent.result )
962 nis_freeresult(global_nisp_ent.result);
963 global_nisp_ent.result = NULL;
964 global_nisp_ent.enum_entry = 0;
967 /*************************************************************************
968 Routine to return the next entry in the nisplus passwd list.
969 *************************************************************************/
970 BOOL pdb_getsampwent(SAM_ACCOUNT *user)
972 int enum_entry = (int)(global_nisp_ent.enum_entry);
973 nis_result *result = global_nisp_ent.result;
976 DEBUG(0,("SAM_ACCOUNT is NULL.\n"));
980 if (result == NULL ||
981 enum_entry < 0 || enum_entry >= (NIS_RES_NUMOBJ(result) - 1))
986 if(!make_sam_from_nisp_object(user, &NIS_RES_OBJECT(result)[enum_entry]) )
988 DEBUG(0,("Bad SAM_ACCOUNT entry returned from NIS+!\n"));
991 (int)(global_nisp_ent.enum_entry)++;
995 /*************************************************************************
996 Routine to search the nisplus passwd file for an entry matching the username
997 *************************************************************************/
998 BOOL pdb_getsampwnam(SAM_ACCOUNT * user, const char *sname)
1000 /* Static buffers we will return. */
1001 nis_result *result = NULL;
1004 char *pfile = lp_smb_passwd_file();
1009 DEBUG(0, ("No SMB password file set\n"));
1012 if( strrchr( pfile, '/') )
1013 pfile = strrchr( pfile, '/') + 1;
1015 slprintf(nisname, sizeof(nisname)-1, "[name=%s],%s.org_dir", sname, pfile);
1016 DEBUG(10, ("search by nisname: %s\n", nisname));
1018 /* Search the table. */
1020 if(!(result = nisp_get_nis_list(nisname, 0)))
1025 ret = make_sam_from_nisresult(user, result);
1026 nis_freeresult(result);
1031 /*************************************************************************
1032 Routine to search the nisplus passwd file for an entry matching the username
1033 *************************************************************************/
1035 BOOL pdb_getsampwsid(SAM_ACCOUNT * user, DOM_SID *sid)
1038 if (!sid_peek_check_rid(get_global_sam_sid(), sid, &rid))
1040 return pdb_getsampwrid(user, rid);
1043 static BOOL pdb_getsampwrid(SAM_ACCOUNT * user, uint32 rid)
1048 char *sp, *p = lp_smb_passwd_file();
1053 DEBUG(0, ("no SMB password file set\n"));
1057 if( (sp = strrchr( p, '/' )) )
1058 safe_strcpy(pfiletmp, sp+1, sizeof(pfiletmp)-1);
1060 safe_strcpy(pfiletmp, p, sizeof(pfiletmp)-1);
1061 safe_strcat(pfiletmp, ".org_dir", sizeof(pfiletmp)-strlen(pfiletmp)-1);
1063 nisname = make_nisname_from_user_rid(rid, pfiletmp);
1065 DEBUG(10, ("search by rid: %s\n", nisname));
1067 /* Search the table. */
1069 if(!(result = nisp_get_nis_list(nisname, 0)))
1074 ret = make_sam_from_nisresult(user, result);
1075 nis_freeresult(result);
1080 /*************************************************************************
1081 Routine to remove entry from the nisplus smbpasswd table
1082 *************************************************************************/
1083 BOOL pdb_delete_sam_account(SAM_ACCOUNT * user)
1086 char *pfile = lp_smb_passwd_file();
1088 nis_result *result, *delresult;
1093 DEBUG(0, ("no SAM_ACCOUNT specified!\n"));
1097 sname = pdb_get_username(user);
1101 DEBUG(0, ("no SMB password file set\n"));
1104 if( strrchr( pfile, '/') )
1105 pfile = strrchr( pfile, '/') + 1;
1107 slprintf(nisname, sizeof(nisname)-1, "[name=%s],%s.org_dir", sname, pfile);
1109 /* Search the table. */
1111 if( !(result = nisp_get_nis_list(nisname,
1112 MASTER_ONLY|FOLLOW_LINKS|FOLLOW_PATH|\
1113 EXPAND_NAME|HARD_LOOKUP))) {
1117 if(result->status != NIS_SUCCESS || NIS_RES_NUMOBJ(result) <= 0) {
1118 /* User not found. */
1119 DEBUG(0,("user not found in NIS+\n"));
1120 nis_freeresult(result);
1124 obj = NIS_RES_OBJECT(result);
1125 slprintf(nisname, sizeof(nisname)-1, "[name=%s],%s.%s", sname, obj->zo_name,
1128 DEBUG(10, ("removing name: %s\n", nisname));
1129 delresult = nis_remove_entry(nisname, obj,
1130 MASTER_ONLY|REM_MULTIPLE|ALL_RESULTS|FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP);
1132 nis_freeresult(result);
1134 if(delresult->status != NIS_SUCCESS) {
1135 DEBUG(0, ("NIS+ table update failed: %s %s\n",
1136 nisname, nis_sperrno(delresult->status)));
1137 nis_freeresult(delresult);
1140 nis_freeresult(delresult);
1144 /************************************************************************
1145 Routine to add an entry to the nisplus passwd file.
1146 *************************************************************************/
1147 BOOL pdb_add_sam_account(SAM_ACCOUNT * newpwd)
1153 nis_result *result = NULL,
1160 * 1. find user domain.
1161 * a. try nis search in passwd.org_dir - if found use domain from result.
1162 * b. try getpwnam. this may be needed if user is defined
1163 * in /etc/passwd file (or elsewere) and not in passwd.org_dir.
1164 * if found, use host default domain.
1165 * c. exit with False - no such user.
1168 * a. find smbpasswd table
1169 * search pfile in user domain if not found, try host default
1171 * b. smbpasswd domain is found, fill data and add entry.
1173 * pfile should contain ONLY table name, org_dir will be concated.
1174 * so, at first we will clear path prefix from pfile, and
1175 * then we will use pfiletmp as playground to put together full
1177 * such approach will make it possible to specify samba private dir
1178 * AND still use NIS+ table. as all domain related data is normally
1179 * stored in org_dir.DOMAIN, this should be ok do do.
1182 pfile = lp_smb_passwd_file();
1183 if( strrchr( pfile, '/') )
1184 pfile = strrchr( pfile, '/') + 1;
1187 * Check if user is already there.
1189 safe_strcpy(pfiletmp, pfile, sizeof(pfiletmp)-1);
1190 safe_strcat(pfiletmp, ".org_dir",
1191 sizeof(pfiletmp)-strlen(pfiletmp)-1);
1193 if(pdb_get_username(newpwd) != NULL) {
1194 nisname = make_nisname_from_name(pdb_get_username(newpwd),
1200 if(!(result = nisp_get_nis_list(nisname, MASTER_ONLY|FOLLOW_LINKS|\
1201 FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP))) {
1204 if (result->status != NIS_SUCCESS &&
1205 result->status != NIS_NOTFOUND) {
1206 DEBUG(3, ( "nis_list failure: %s: %s\n",
1207 nisname, nis_sperrno(result->status)));
1208 nis_freeresult(result);
1212 if (result->status == NIS_SUCCESS && NIS_RES_NUMOBJ(result) > 0)
1214 DEBUG(3, ("User already exists in NIS+ password db: %s\n",
1216 nis_freeresult(result);
1220 nis_freeresult(result); /* no such user, free results */
1223 * check for user in unix password database. we need this to get
1224 * domain, where smbpasswd entry should be stored.
1227 nisname = make_nisname_from_name(pdb_get_username(newpwd),
1230 result = nisp_get_nis_list(nisname,
1231 MASTER_ONLY|FOLLOW_LINKS|FOLLOW_PATH|\
1232 EXPAND_NAME|HARD_LOOKUP);
1234 if (result->status != NIS_SUCCESS || NIS_RES_NUMOBJ(result) <= 0)
1236 struct passwd *passwd;
1237 DEBUG(3, ("nis_list failure: %s: %s\n",
1238 nisname, nis_sperrno(result->status)));
1239 nis_freeresult(result);
1241 if (!(passwd = getpwnam_alloc(pdb_get_username(newpwd)))) {
1242 /* no such user in system! */
1245 passwd_free(&passwd);
1248 * user is defined, but not in passwd.org_dir.
1252 safe_strcpy(pfiletmp, pfile, sizeof(pfiletmp)-1);
1253 safe_strcat(pfiletmp, ".", sizeof(pfiletmp)-strlen(pfiletmp)-1);
1254 safe_strcat(pfiletmp, NIS_RES_OBJECT(result)->zo_domain,
1255 sizeof(pfiletmp)-strlen(pfiletmp)-1);
1256 nis_freeresult(result); /* not needed any more */
1258 tblresult = nisp_get_nis_list(pfiletmp,
1259 MASTER_ONLY|FOLLOW_LINKS|\
1260 FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP);
1263 if (local_user || tblresult->status != NIS_SUCCESS)
1267 * smbpasswd table not found in user domain, fallback to
1270 if (!local_user) /* free previous failed search result */
1271 nis_freeresult(tblresult);
1273 safe_strcpy(pfiletmp, pfile, sizeof(pfiletmp)-1);
1274 safe_strcat(pfiletmp, ".org_dir",
1275 sizeof(pfiletmp)-strlen(pfiletmp)-1);
1276 tblresult = nis_lookup(pfiletmp, MASTER_ONLY|FOLLOW_LINKS|\
1277 FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP);
1278 if (tblresult->status != NIS_SUCCESS)
1280 /* still nothing. bail out */
1281 nis_freeresult(tblresult);
1282 DEBUG(3, ( "nis_lookup failure: %s\n",
1283 nis_sperrno(tblresult->status)));
1286 /* we need full name for nis_add_entry() */
1287 safe_strcpy(pfiletmp, pfile, sizeof(pfiletmp)-1);
1288 safe_strcat(pfiletmp, ".", sizeof(pfiletmp)-strlen(pfiletmp)-1);
1289 safe_strcat(pfiletmp, NIS_RES_OBJECT(tblresult)->zo_domain,
1290 sizeof(pfiletmp)-strlen(pfiletmp)-1);
1293 memset((char *)&new_obj, 0, sizeof (new_obj));
1294 /* fill entry headers */
1295 /* we do not free these. */
1296 new_obj.zo_name = NIS_RES_OBJECT(tblresult)->zo_name;
1297 new_obj.zo_owner = NIS_RES_OBJECT(tblresult)->zo_owner;
1298 new_obj.zo_group = NIS_RES_OBJECT(tblresult)->zo_group;
1299 new_obj.zo_domain = NIS_RES_OBJECT(tblresult)->zo_domain;
1301 new_obj.zo_access = NIS_RES_OBJECT(tblresult)->zo_access;
1302 new_obj.zo_ttl = NIS_RES_OBJECT(tblresult)->zo_ttl;
1304 new_obj.zo_data.zo_type = ENTRY_OBJ;
1305 new_obj.EN_data.en_type =
1306 NIS_RES_OBJECT(tblresult)->TA_data.ta_type;
1308 ta_maxcol = NIS_RES_OBJECT(tblresult)->TA_data.ta_maxcol;
1310 if(!(ecol = (entry_col*)malloc(ta_maxcol*sizeof(entry_col)))) {
1311 DEBUG(0, ("memory allocation failure\n"));
1312 nis_freeresult(tblresult);
1316 memset((char *)ecol, 0, ta_maxcol*sizeof (entry_col));
1317 new_obj.EN_data.en_cols.en_cols_val = ecol;
1318 new_obj.EN_data.en_cols.en_cols_len = ta_maxcol;
1320 init_nisp_from_sam(&new_obj, newpwd, NULL);
1322 DEBUG(10, ( "add NIS+ entry: %s\n", nisname));
1323 result = nis_add_entry(pfiletmp, &new_obj, 0);
1325 free(ecol); /* free allocated entry space */
1327 if (result->status != NIS_SUCCESS)
1329 DEBUG(3, ( "NIS+ table update failed: %s\n",
1330 nisname, nis_sperrno(result->status)));
1331 nis_freeresult(tblresult);
1332 nis_freeresult(result);
1336 nis_freeresult(tblresult);
1337 nis_freeresult(result);
1342 /************************************************************************
1343 Routine to modify the nisplus passwd entry.
1344 ************************************************************************/
1345 BOOL pdb_update_sam_account(SAM_ACCOUNT * newpwd)
1347 nis_result *result, *addresult;
1352 char *pfile = lp_smb_passwd_file();
1358 DEBUG(0, ("no SMB password file set\n"));
1361 if( strrchr( pfile, '/') )
1362 pfile = strrchr( pfile, '/') + 1;
1364 slprintf(nisname, sizeof(nisname)-1, "[name=%s],%s.org_dir",
1365 pdb_get_username(newpwd), pfile);
1367 DEBUG(10, ("search by name: %s\n", nisname));
1369 /* Search the table. */
1371 if( !(result = nisp_get_nis_list(nisname, MASTER_ONLY|FOLLOW_LINKS|\
1372 FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP))) {
1376 if(result->status != NIS_SUCCESS || NIS_RES_NUMOBJ(result) <= 0) {
1377 /* User not found. */
1378 DEBUG(0,("user not found in NIS+\n"));
1379 nis_freeresult(result);
1383 obj = NIS_RES_OBJECT(result);
1384 DEBUG(6,("entry found in %s\n", obj->zo_domain));
1386 /* we must create new stub object with EN_MODIFIED flag.
1387 this is because obj from result is going to be freed and
1388 we do not want to break it or cause memory leaks or corruption.
1391 memmove((char *)&new_obj, obj, sizeof (new_obj));
1392 ta_maxcol = obj->TA_data.ta_maxcol;
1394 if(!(ecol = (entry_col*)malloc(ta_maxcol*sizeof(entry_col)))) {
1395 DEBUG(0, ("memory allocation failure\n"));
1396 nis_freeresult(result);
1400 memmove((char *)ecol, obj->EN_data.en_cols.en_cols_val,
1401 ta_maxcol*sizeof (entry_col));
1402 new_obj.EN_data.en_cols.en_cols_val = ecol;
1403 new_obj.EN_data.en_cols.en_cols_len = ta_maxcol;
1405 if ( init_nisp_from_sam(&new_obj, newpwd, obj) == True ) {
1406 slprintf(nisname, sizeof(nisname)-1, "[name=%s],%s.%s",
1407 pdb_get_username(newpwd), pfile, obj->zo_domain);
1409 DEBUG(10, ("NIS+ table update: %s\n", nisname));
1411 nis_modify_entry(nisname, &new_obj,
1412 MOD_SAMEOBJ | FOLLOW_PATH | EXPAND_NAME | HARD_LOOKUP);
1414 if(addresult->status != NIS_SUCCESS) {
1415 DEBUG(0, ("NIS+ table update failed: %s %s\n",
1416 nisname, nis_sperrno(addresult->status)));
1417 nis_freeresult(addresult);
1418 nis_freeresult(result);
1423 DEBUG(6,("password changed\n"));
1424 nis_freeresult(addresult);
1426 DEBUG(6,("nothing to change!\n"));
1430 nis_freeresult(result);
1436 void nisplus_dummy_function(void);
1437 void nisplus_dummy_function(void) { } /* stop some compilers complaining */
1438 #endif /* WITH_NISPLUSSAM */