Modifying User and Location fields using API

plawrence
Contributor II

Hi all

Does anyone know of a way to clear out the contents of the User & Location fields for Mobile Devices using the API? Writing a new username into those fields using the API appears to perform an LDAP lookup, but it only updates the rest of the fields (email, department, position, etc) if they are empty. I'd like to empty out the fields then run a script to repopulate the user information.

Also, it seems that updating the User & Location information on one device will change that users details on all other devices with the same username. Is this expected behaviour?

Patrick

5 REPLIES 5

davidacland
Honored Contributor II
Honored Contributor II

I haven't tried it that way round but I would assume you could just upload the xml file with no data between the tags, e.g:

<computer>
  <location>
    <username></username>
    <real_name></real_name>
    <email_address></email_address>
    <position></position>
    <phone></phone>
    <department></department>
    <building></building>
    <room><room/>
  </location>
</computer>

cvgs
Contributor II

In my experience, to clear a value, you mustn't send "<value/>", but you have to omit that tag completely in the PUT request. Might be a bug, might be a feature, YMMV, and so on :-)

brandonusher
Contributor II
Does anyone know of a way to clear out the contents of the User & Location fields for Mobile Devices using the API?

I have always sent the following and it clears out the information of a user and location information:

<computer>
    <location>
        <username/>
    </location>
</computer>

As for

Also, it seems that updating the User & Location information on one device will change that users details on all other devices with the same username. Is this expected behaviour?

Yes, that is expected behavior and makes sense as well. The user information is looked up based on username, which then goes to userID. The userID stores all the information for a user. If you update it in one place, it only makes sense that it updates everywhere else. Otherwise you would have a separate user for each device but with all the same usernames, which could get really confusing and not very well designed from a database side of things

plawrence
Contributor II

Thanks for the replies everyone. We've got it working, it looks like you need to remove the Username before you can blank out the other fields. Processing each record twice solves the problem.

apizz
Valued Contributor

Sorry, API n00b here. How are you writing / scripting this command to clear the User & Location data for a particular JSS record? @plawrence @brandonusher @davidacland