Hi Sven,
Here is my code for Editing a User in c# maybe it will be of some help.
#region SoapEnvelope
soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
</soap:Envelope>");
XmlElement soapBody =
soapEnvelopeXml.CreateElement("soap:Body",
soapEnvelopeXml.DocumentElement.NamespaceURI);
XmlElement ManageUser =
soapEnvelopeXml.CreateElement("ManageUser",
"http://www.sipfoundry.org/2007/08/21/ConfigService");
XmlElement searchUser = soapEnvelopeXml.CreateElement("search");
XmlElement searchUserMethod =
soapEnvelopeXml.CreateElement("byUserName");
//Edit Elements we need one per property
XmlElement pinEdit = soapEnvelopeXml.CreateElement("edit");
XmlElement lastNameEdit = soapEnvelopeXml.CreateElement("edit");
XmlElement firstNameEdit = soapEnvelopeXml.CreateElement("edit");
XmlElement sipPasswordEdit = soapEnvelopeXml.CreateElement("edit");
XmlElement aliasesEdit = soapEnvelopeXml.CreateElement("edit");
XmlElement groupsEdit = soapEnvelopeXml.CreateElement("edit");
//Add values to searchmethod node
searchUserMethod.AppendChild(soapEnvelopeXml.CreateTextNode(user.extension));
//Setup propert/value pairs
XmlElement pinPropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement pinValueElement = soapEnvelopeXml.CreateElement("value");
XmlElement lastNamePropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement lastNameValueElement =
soapEnvelopeXml.CreateElement("value");
XmlElement firstNamePropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement firstNameValueElement =
soapEnvelopeXml.CreateElement("value");
XmlElement sipPasswordPropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement sipPasswordValueElement =
soapEnvelopeXml.CreateElement("value");
XmlElement aliasesPropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement aliasesValueElement =
soapEnvelopeXml.CreateElement("value");
XmlElement groupsPropertyElement =
soapEnvelopeXml.CreateElement("property");
XmlElement groupsValueElement =
soapEnvelopeXml.CreateElement("value");
//Set up property names
lastNamePropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("lastName"));
firstNamePropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("firstName"));
sipPasswordPropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("sipPassword"));
aliasesPropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("aliases"));
groupsPropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("groups"));
pinPropertyElement.AppendChild(soapEnvelopeXml.CreateTextNode("pintoken"));
//assign property values
lastNameValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(user.lname));
firstNameValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(user.fname));
sipPasswordValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(user.sipPassword));
aliasesValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(user.ename));
groupsValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(user.userGroup));
//must md5 has the pin
if (user.pintoken.Length > 0)
{
using (MD5 md5Hash = MD5.Create())
{
string hash = GetMd5Hash(md5Hash,
user.extension+":"+"acns.colostate.edu:"+user.pintoken);
pinValueElement.AppendChild(soapEnvelopeXml.CreateTextNode(hash));
}
}
//add search node
searchUser.AppendChild(searchUserMethod);
//append find elements to manager user
ManageUser.AppendChild(searchUser);
//Add property value nodes to actionElement
if (user.lname.Length > 0)
{
lastNameEdit.AppendChild(lastNamePropertyElement);
lastNameEdit.AppendChild(lastNameValueElement);
ManageUser.AppendChild(lastNameEdit);
}
if (user.fname.Length > 0)
{
firstNameEdit.AppendChild(firstNamePropertyElement);
firstNameEdit.AppendChild(firstNameValueElement);
ManageUser.AppendChild(firstNameEdit);
}
if (user.sipPassword.Length > 0)
{
sipPasswordEdit.AppendChild(sipPasswordPropertyElement);
sipPasswordEdit.AppendChild(sipPasswordValueElement);
ManageUser.AppendChild(sipPasswordEdit);
}
if (user.ename.Length > 0)
{
aliasesEdit.AppendChild(aliasesPropertyElement);
aliasesEdit.AppendChild(aliasesValueElement);
ManageUser.AppendChild(aliasesEdit);
}
if (user.userGroup.Length > 0)
{
RemoveUserGroups(user);
AddUserGroups(user);
}
if (user.pintoken.Length > 0)
{
pinEdit.AppendChild(pinPropertyElement);
pinEdit.AppendChild(pinValueElement);
ManageUser.AppendChild(pinEdit);
}
//add elements to soap body
soapBody.AppendChild(ManageUser);
//attach soap body to soap envelope
soapEnvelopeXml.DocumentElement.AppendChild(soapBody);
Kyle
On Sun, Jul 1, 2012 at 6:13 PM, Sven Evensen <[email protected]> wrote:
> Thanks George, but I still dont get it, I am not that familiar with this
> part of the code.
>
> Our deleteUser looks like this
>
> public void deleteSipXECSUser( String sipUserId ) {
>
> log.debug (" removeSipXECSUser id : " + sipUserId);
> ObjectFactory objectFactory = new ObjectFactory();
>
> // Ask for user
> UserSearch usearch = new UserSearch();
> usearch.setByUserName( sipUserId );
>
> ManageUser mUser = new ManageUser();
> mUser.setSearch(usearch);
> JAXBElement jelement = objectFactory.createManageUserDeleteUser( true );
> mUser.setDeleteUser (jelement);
>
> us.manageUser( mUser );
> }
>
> while our editUser looks like this:
>
> public void editSipXECSUser(
> String sipUserId, String sipUserPassword,
> String firstName, String surName,
> String oldGroupId, String newGroupId ) {
>
> log.debug (" removeSipXECSUser id : " + sipUserId);
>
> User existingUser = getCurrentUser ( sipUserId );
>
> if( existingUser == null ) {
> addSipXECSUser( sipUserId, sipUserPassword, firstName, surName, newGroupId
> );
> editUserToUserGroup ( sipUserId, oldGroupId, newGroupId );
> return;
> }
>
> // Ask for user
> UserSearch usearch = new UserSearch();
> usearch.setByUserName( sipUserId );
>
> ManageUser mUser = new ManageUser();
> mUser.setSearch( usearch );
>
> mUser.getEdit( ); //??
>
> editUserToUserGroup (sipUserId, oldGroupId, newGroupId);
> }
>
>
>
> On Sun, Jul 1, 2012 at 9:58 PM, George Niculae <[email protected]> wrote:
>>
>> On Sun, Jul 1, 2012 at 11:52 PM, Sven Evensen <[email protected]>
>> wrote:
>> > Our application is adding and deleting users using SOAP just fine, But I
>> > want to edit name and sipPassword and I just cannot figure out how. I
>> > aasume
>> > ManagerUser is to be used somehow.
>> >
>> > Any tips?
>> >
>>
>> Use ManageUser same way you use it for deleting user but with edit
>> operation - you can pass sipPassword and userName/lastName/firstName
>> with an User object. Check sipxconfig.wsdl,
>> <xsd:element name="ManageUser">
>> <xsd:complexType>
>> <xsd:sequence>
>> <xsd:element name="search" type="tns:UserSearch"
>> minOccurs="1" maxOccurs="1" />
>> <xsd:element name="edit" type="tns:Property"
>> maxOccurs="unbounded" />
>> <xsd:element name="deleteUser" type="xsd:boolean"
>> nillable="true" minOccurs="0" maxOccurs="1" />
>> <xsd:element name="addGroup" type="xsd:string"
>> nillable="true" minOccurs="0" maxOccurs="1" />
>> <xsd:element name="removeGroup" type="xsd:string"
>> nillable="true" minOccurs="0" maxOccurs="1" />
>> <xsd:element name="updateBranch" type="xsd:string"
>> nillable="true" minOccurs="0" maxOccurs="1" />
>> </xsd:sequence>
>> </xsd:complexType>
>> </xsd:element>
>>
>> and User type
>>
>>
>> <xsd:complexType name="User">
>> <xsd:sequence>
>> <xsd:element name="userName" type="xsd:string" minOccurs="1"
>> maxOccurs="1" />
>> <xsd:element name="pintoken" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> <xsd:element name="lastName" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> <xsd:element name="firstName" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> <xsd:element name="sipPassword" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> <xsd:element name="aliases" type="xsd:string"
>> nillable="true" minOccurs="0" maxOccurs="unbounded" />
>> <xsd:element name="emailAddress" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> <xsd:element name="groups" type="xsd:string" nillable="true"
>> minOccurs="0" maxOccurs="unbounded" />
>> <xsd:element name="permissions" type="xsd:string"
>> nillable="true" minOccurs="0" maxOccurs="unbounded" />
>> <xsd:element name="branchName" type="xsd:string"
>> nillable="true" maxOccurs="1" />
>> </xsd:sequence>
>> </xsd:complexType>
>>
>>
>> George
>> _______________________________________________
>> sipx-users mailing list
>> [email protected]
>> List Archive: http://list.sipfoundry.org/archive/sipx-users/
>
>
>
>
> --
>
> Sven Evensen, Operations Consultant
>
> OnRelay
>
> Elizabeth House │ 39 York Road, London SE1 7NQ, UK │ +44 (0) 207 902 8123 │
> mailto:[email protected] │ www.onrelay.com
>
>
> This electronic message transmission contains information from OnRelay,
> Ltd., that may be confidential or privileged. The information is intended
> solely for the recipient and use by any other party is not authorised. If
> you are not the intended recipient, be aware that any disclosure, copying,
> distribution or use of the contents of this information or any attachment,
> is prohibited. If you have received this electronic transmission in error,
> please notify us immediately by electronic mail ([email protected]) and
> delete this message, along with any attachments, from your computer.
> Registered in England No 04006093 ¦ Registered Office 1st Floor, 236 Gray's
> Inn Road, London WC1X 8HB
>
>
--
Kyle Haefner, M.S.
Communication Systems Programmer
Colorado State University
Fort Collins, CO
Phone: 970-491-1012
Email: [email protected]
01010010 01100101 01100001 01101100 00100000 01101101 01100101
01101110 00100000 01110000 01110010 01101111 01100111 01110010
01100001 01101101 00100000 01101001 01101110 00100000 01100010
01101001 01101110 01100001 01110010 01111001 00101110
_______________________________________________
sipx-users mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-users/