Change user password with LS

To change the user password using Script, I wrote a simple exe file using the C API. First compile the code bellow then you can use it from LS by executing it with the shell function.

You can send me a mail at ysabag@iba.co.il and I'll send you the exe.

Put the following code in: ChangePassword.c

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>

#include <lapicinc.h>
#include <lapiplat.h>
#include <osenv.h>
#include <kfm.h>

char    OrigPassword[20];
char    NewPassword[20];
char    IDFileSpec[MAXENVVALUE+1];


  if (error)

if (argc<3)
	LAPI_RETURN ("Syntax ChangePassword.exe KeyFileName OrigPassword NewPassword");

if (argc==3)  
	strcpy(OrigPassword, argv[1]);
	strcpy(NewPassword, argv[2]);

/* Get the current user's id file path specification */
	if (error=!OSGetEnvironmentString ("KeyFileName", IDFileSpec, MAXENVVALUE))
		printf ("Cannot locate current id file, using NULL for pIDFilen");
		LAPI_RETURN (ERR(error));

	strcpy(IDFileSpec, argv[1]);
	strcpy(OrigPassword, argv[2]);
	strcpy(NewPassword, argv[3]);


if (error = SECKFMChangePassword (IDFileSpec, OrigPassword, NewPassword)) 
   LAPI_RETURN (ERR(error));


The Make file :

!include <ntwin32.mak>

# The name of the program.

PROGNAME = ChangePassword

# DEC Alpha doesn't want the structures to be packed so we use the CPU
# type to conditionally add it as part of compile string
!IF "$(CPU)" == "ALPHA"
cpuflags = 
cpuflags = /Zp

# Dependencies


# Compilation command.  

    $(cc) $(cdebug) $(cflags) $(cpuflags) /DNT $(cvars) $*.c

# Link command.
    $(link) $(linkdebug) $(conflags) -out:$@ $** notes0.obj $(conlibs) 
        notes.lib user32.lib

This was first published in October 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.