URGENT : UPDATING END USER CONTROLLED PROFILE

Version 1
    This document was generated from CDN thread

    Created by: Abhishek Goud on 03-11-2009 05:34:40 AM
    Hi,
     
    I am trying to update the End User's Controlled Profile ... Not the Default Profile. If someone can give me the SQL Query for it, it would be great!
     
    Currently,
    I am able to set the default profile of the end user to the profile I need but in order to set it to the wanted profile, I need to first update the "Controlled Profiles" of the End User. How to do that in SQL or C#? ... I am stuck !
     
    Thanks in advance !
     
    Abhishek

    Subject: RE: URGENT : UPDATING END USER CONTROLLED PROFILE
    Replied by: Stephan Steiner on 03-11-2009 09:35:05 PM
    what about updateUser? I don't have the schema in front of me but I know for a fact that it can be used to set both the controlled profiles as well as the controlled devices and the default device.
     
    @edit: since you're using proxies (I know why I'm not.. I don't trust those schemas at all), the sql way was already told to you in the other thread:
     
    xml += "<sql>update enduserdevicemap set defaultprofile = 't'
    where fkenduser in (select pkid from enduser where userid =
    '"+userID+"') and fkdevice in (select pkid from device where name =
    '"+defaultProfile+"')</sql>";
     
    If you take a bit of code like that, it would be useful to look at the database dictionary for the ccm release you're working against (all right up here on the developer.cisco.com site in the AXL documentation section: http://developer.cisco.com/c/document_library/get_file?folderId=192390&name=DLFE-18909.pdf).. the enduserdevicemap links users and devices as well as users and device profiles (since a device is stored in the same table as a device profile it's all in the same table)..
     
    so
     
    SELECT * FROM enduserdevicemapWHERE fkenduser = (SELECT pkid FROM enduser WHERE userid =
    '"+userID+"')
     
    will get you all devices and device profiles associated with user userId. Now you can do an insert as well:
     
    INSERT INTO enduserdevicemap (fkdevice, fkenduser, pkid, tkuserassociation) VALUES ((SELECT pkid FROM device WHERE name = 'my profile name'), (SELECT pkid FROM enduser WHERE userId = 'my user id'), newid(), 4)
     
    That's all written from memory so the syntax could be correct, and tkuserassociation could have the wrong value (I checked the definition of the table typeuserassociation and it has 5 values.. I'm presuming it starts at 0 and profile is option 5 so 4 is the value... but you can associate a profile via ccmadmin, then you can look at the enduserdevicemap entry and note the tkuserassociation value and use that.

    Subject: RE: URGENT : UPDATING END USER CONTROLLED PROFILE
    Replied by: Abhishek Goud on 04-11-2009 05:42:32 AM
    Brilliant ! ... thank you so much Stephen ... your second part of the code ... the "Insert into..." did exactly what I wanted ... thanks a lot!
     
    Abhishek