Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Creating a local user


3 replies to this topic

neouser

neouser
  • Members
  • 4 posts

Posted 05 November 2003 - 19:36

Hi,

I am trying to create a local user account from my installation. I couldn't find resources that talk about this functionality.

So if there is anyone who has an idea how to do it or where to look I would really appreciate it .

Thanks in advance for your help

r.

neouser

neouser
  • Members
  • 4 posts

Posted 07 November 2003 - 16:52

Answering my Unanswered question.

With the help of a friend, to create a new user I launched NET.exe (located in WINSYSDIR) with LaunchAppAndWait(...) and I passed command line parameters to it.

Thanks.
r.

shawn_cme

shawn_cme
  • Members
  • 1 posts

Posted 16 March 2004 - 04:27

Is there a better way of doing this?

Esquimaux

Esquimaux
  • Members
  • 17 posts

Posted 18 March 2004 - 17:53

If your are installing your software on Windows 2000 or later, my prefered method is to use the ADSI COM object to create local user groups.

#define ADS_UF_DONT_EXPIRE_PASSWD 0x00010000
#define ADS_UF_PASSWD_CANT_CHANGE 0X00000040

STRING szUserName, szPassword, szComputerName ;
VARIANT varBuffer;
OBJECT oComputer, oUser;

szComputerName = "MyComputer";
szUserName = "MyUser";
szPassword = "MyPassword";

// Get IADsComputer object
set oComputer = CoGetObject("WinNT://" + szComputerName + ",computer", "");

// Create IADsUser object
set oUser = oDomain.Create("user", szUserName);
oUser.SetInfo();

// Set password
oUser.SetPassword(szPassword);
oUser.SetInfo();

// Activate the user
varBuffer = oUser.Get("UserFlags");
varBuffer = varBuffer | ADS_UF_DONT_EXPIRE_PASSWD |
ADS_UF_PASSWD_CANT_CHANGE;
oUser.Put("UserFlags", varBuffer);
oUser.SetInfo();

etc...

The above code sample does no error checking and no exception handling. However, if done properly, this is a very reliable method to create LOCAL users. Add some try-catch-endcatch and IsObject() checking and you can be very thourough when creating your user account.

The web is full of interesting information on ADSI methods (WinNT for local users handling and LDAP for domain user handling).

Have fun.

The Eskimo


The Eskimo

"Evil shall come upon thee, which thou shalt not know how to deprecate"
- Robert Lowth, eighteenth-century Bishop of Winchester