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

ADSI
plus

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

dsSetProperty userAccountControl


Question:

I am trying to set userAccountControl=66048 with this line IPRSuccess=dsSetProperty(IPRUser, "userAccountControl", "66048") it doesnt seem to be working. I am executing this line after I do the dsSetObj. If I use IPRUser.put("userAccountControl", "66048") it seems to work ok. Anybody know hy this is?

Answer:

First, the return value from the "dsSetProperty" is not very useful so assigning it to a variable looks suspicious. Are you using it to determine if the function was successful? Perhaps setting Errormode(@Off)? Don't use the return value from dsSetPropery to check for success or failure of the function.

Second, the usual practice is to set an "userAccountControl" to disabled before calling "dsSetObj". This is because you cannot set a password on an account until the after it is created. So after dsSetObj you should set a password on the account and then enable the account by removing the disable bit from "userAccountControl".

Third, "userAccountControl" is a bit mask so the usual method for changing it on an existing account is to first call dsGetProperty to get the current mask, add/remove the desired bits and then call dsSetProperty. This helps avoid attempting to set bit combination that the server finds unacceptable.

Finally, while using objUser.Put("userAccountControl", nValue) may appear to work, you will most likely find that that it did not change anything on the server. This is because calling the "put" method only changes the local cached copy of the object and not the actual sever object. You must call the "SetInfo" method to send changes to the server when using COM. If you do with the bits you describe, you will most likely get a COM exception because of an invalid "userAccountControl" bit mask.


Article ID:   W16800
File Created: 2007:07:03:14:26:18
Last Updated: 2007:07:03:14:26:18