Add user to groups C#

Version 1
    This document was generated from CDN thread

    Created by: Mayank Sharma on 24-08-2010 03:47:54 PM
    Hi,
     
    I am experimenting with adding users to the call manager using AXL API. I was able to add a user but was not able to add this user to existing call manager groups like "Standard CCM User".
     
    Adding user:
     
    AXLAPIService service = new AXLAPIService(IP, username, password);
     
                AddUserReq req = new AddUserReq();
     
                XUser user = new XUser();
     
                user.userid = "userid1";
                user.firstname = "John";
                user.lastname = "Doe";
                user.password = "jd1212";
                user.pin = "1234";
                user.telephoneNumber = "1000";
                user.department = "Sales";
                user.associatedDevices = new string[] { "SEP000AB7D111111" };
     
                req.newUser = user;
                service.addUser(req);
    I tried execuing INSERT query into enduserdirgroupmap but I get the SoapException:
    "Method only for queries"
    <font size="2">
    query.sql =
    </font>
    String.Format("INSERT INTO enduserdirgroupmap(fkenduser,fkdirgroup) VALUES('{0}','{1}')", userpkid, "64a8af58-7a0d-4a06-a7e9-d8e033510cea");
    result = service.executeSQLQuery(query);



    Is there a better way of adding a user to groups.
    Thanks,
    Max

     

    Subject: RE: Add user to groups C#
    Replied by: David Staudt on 24-08-2010 04:21:26 PM
    You'll need to use executeSQLUpdate for SQL that performs modifications.  executeSQLQuery is read-only.

    Subject: RE: Add user to groups C#
    Replied by: Mayank Sharma on 24-08-2010 05:07:55 PM
    You'll need to use executeSQLUpdate for SQL that performs modifications.  executeSQLQuery is read-only.

     
    That was easy. Thanks again David. I saw executeSQLUpdate method and thought that was for update only and was looking for executeSQLInsert.
    Do you know what XUser.associatedGroups does?

    Thanks,
    Max

    Subject: RE: Add user to groups C#
    Replied by: David Staudt on 24-08-2010 07:10:15 PM
    I believe XUser.associatedGroups would be present if you were reading user info, i.e. via getUser/getAppUser.  In order to update group membership, you need to use the updateUserGroup request.  Note that only the later versions of UCM allow you to specify single members to add/remove via updateUserGroup (addMembers/removeMembers)- otherwise you will have to read the existing list of users in a Group via getUserGroup, add/remove individual members from the list, then submit the entire list via updateUserGroup.  If there are thousands of users this becomes unworkable, and directly SQL is recommended.

    Subject: RE: Add user to groups C#
    Replied by: Mayank Sharma on 25-08-2010 12:38:14 PM
    I believe XUser.associatedGroups would be present if you were reading user info, i.e. via getUser/getAppUser.  In order to update group membership, you need to use the updateUserGroup request.  Note that only the later versions of UCM allow you to specify single members to add/remove via updateUserGroup (addMembers/removeMembers)- otherwise you will have to read the existing list of users in a Group via getUserGroup, add/remove individual members from the list, then submit the entire list via updateUserGroup.  If there are thousands of users this becomes unworkable, and directly SQL is recommended.


    Sounds good. Thanks.