WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

wntUserGetDat Syntax and Flags

Keywords:   wntUserGetDat   wntUserAddDat  wxxUserSetDat wxxUserGetDat

Question:

I need to know if the following is possible and what the proper syntax is.

I want to use the wntUserGetDat function to get a list of the users who's account is disabled, or no password is required, etc. for audit purposes.

What is the syntax usage for the "flags" element.

Answer:

Something like:
        user="joe"
        flags=wntUserGetDat("\\SERVER",user,"flags")
        if flags & 2
           Message(user,"Account Disabled")
        endif
        if flags & 32
           Message(user,"Password not required")
        endif

wntUserSetDat Functionality Tips

Question:

I want to be able use "Admin" rights to set information in the users account, even though the logged on user does not have those rights. Or any work around ideas....?

Answer:

See the Win32 Network Extender function wntRunAsUser.


Renaming a User Account

Question:

There is a constant need to update user attributes in our NT user database. Users get married and their last names change, or a transfer of a VP from one branch into ours could force us to change the username of any lower ranking employee with the same username.

I have used wntUserSetDat with success in the past to automate account updates when Home directories, user profiles, login scripts and/or profiles are changed. For some reason I can't seem to rename an existing NT user account?

The syntax is:

        wntUserSetDat("\\%PDC%",Old_Username,"name",New_Username)
The command seems to process without any errors, but when completed, the username stays exactly the same..

Answer:

This is true. wntUserSetDat cannot rename an account. See the Win32 Network Extender function wntUserRename.


Undocumented 'Flags' bit for wntUserXXXDat()

Question:

I'm working with WinBatch 99B, WIL v2.7bbs and the 11008 version of wwwnt32i.dll. When running the extender on my WinNT v4.0 SP4 Workstation, I get an error if I try to set the flags for a workstation user account to a value that does not have bit 0 enabled. Bit zero is not documented. The result of LastError() indicates that error # is 531, but this value is undocumented in the help file for the Win32 network extender.

If I perform a wntUserGetDat() on the flags for a normal account with none of the flags checked in User Manager I end up with a result of 513, which is 512 (Normal User) plus 1 (bit 0).

Does anybody have an idea as to what this bit is supposed to do when enabled?

Answer:

Bit 0 is always set. (see below).

wntUserSetDat and Flags

Question:

When using wntusersetdat I can change user information except for flags. When I attempt to set accountdisable (2). The extender returns invalid parameter. The call looks like:
 
rc=wntusersetdat(usermachine,"userid","flags",2)
I'm using WinBatch 32 97D
Wil Version 2.4dbp

Any idea's?

Answer:

The trick is that you have to set ALL the flags. With the command as you have it, you are clearing ALL the flags except 2. Probably an illegal combination.

Try something like:

        myflags=wntusergetdat(usermachine,"userid","flags")
        myflags=myflags | 2
        rc=wntusersetdat(usermachine,"userid","flags",myflags)
Alternatively, all you need to do to make it work is to add a 1 to the value of the flags that you are setting.

Ex:

        wntUserAddDat("flags",512+1)  ;Normal Account 

Similar Question:

I want to disable a user account in a windows nt domain. The server is the primary domain controler.
	AddExtender("WWWNT32I.DLL")
	wntUserSetDat("\\server","user","flags",2)
The above syntax creates an error message "error 531 invalid parameter". I've tried a lot of variations on this and the help file doesn't seem to clarify what the correct syntax might be. Can someone point out the error of my ways?

Answer:

Looks vaguely ok. But here's what I would try.
	flags=wntUserGetDat("\\server","jdoe","flags")
	theflags=flags|2
	wntUserSetDat("\\server","jdoe","flags",theflags)
to preserve the value of the other flags. Just the 2 flag by itself may be illegal.

How to UNLOCK a User Account and "NOT" Other Settings:

Question:

I know my user account is set to UF_LOCKOUT. How do I UNLOCK a user account?

Answer:

Here's the recommended solution:

To get the flag settings for the current user:

	flags = w9XUserGetDat("\\MYSERVER", "jdoe", "flags")
Unset the bit with:
	flags = flags & ~16
	w9XUserSetDat("\\MYSERVER", "jdoe", "flags", flags)
~ is the bitwise NOT operator.

Flag for "User must Change Password at Next Logon"

Question:

In the wntUserSetDat function, there are a number of flags for setting various user account stuff.

I would like (if possible) to have the "User must Change Password at Next Logon" (a checkbox option in User Manager) added to the list of optional flags for this function

Answer:

It's already there: "password_expired" keyword.
Article ID:   W13585
Filename:   wNTUserXXXDat Function and Flags.txt
File Created: 2001:03:01:14:24:18
Last Updated: 2001:03:01:14:24:18