예제 #1
0
        /**
         * <summary>
         * Retrieve the permissions for a specific user.
         * </summary>
         *
         * <param name="username">      The name of the user</param>
         * <param name="actorPerms">	Receives the permissions for the user, must not be null.</param>
         *
         * <returns><c>ErrorCode.EC_NOERROR</c> upon success, otherwise errors returned
         * could be but are not limited to:<br/>
         * <table border="0" cellpadding="3" cellspacing="0">
         * <tr><td><c>ErrorCode.EC_NETWORKERROR</c></td>
         *				<td>A networking error has occurred and the conneciton
         *					is nolonger valid.
         *				</td></tr>
         * <tr><td><c>ErrorCode.EC_DOESNOTEXIST</c></td>
         *				<td>The specified user does not exist on the SAFMQ server, or the
         *					user has no permissions set.
         *				</td></tr>
         * </table>
         * </returns>
         */
        public ErrorCode UserGetPermissions(string username, ActorPermissions actorPerms)
        {
            USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS	parms =  new USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS();
            ErrorCode										ret = ErrorCode.EC_NETWORKERROR;

            parms.username = username;
            try {
                output.Write(Safmq.CMD_USER_GET_PERMS);
                parms.Write(output);
                output.Flush();
                ret = getResponseCode();
                if (ret == ErrorCode.EC_NOERROR) {
                    USER_GET_PERMS_GROUP_GET_PERMS_RESPONSE_data	perms = new USER_GET_PERMS_GROUP_GET_PERMS_RESPONSE_data();
                    perms.Read(input);
                    actorPerms.ModifyQueues = (perms.modify_queues != 0);
                    actorPerms.ModifyUsers = (perms.modify_users != 0);
                    actorPerms.ModifyGroups = (perms.modify_groups != 0);
                }
            } catch (Exception) {
                ret = ErrorCode.EC_NETWORKERROR;
            }
            return ret;
        }
예제 #2
0
        /**
         * <summary>
         * Delete a user from the SAFMQ server.
         * </summary>
         *
         * <param name="username"> The name of the suer to delete.</param>
         *
         * <returns><c>ErrorCode.EC_NOERROR</c> upon success, otherwise errors returned
         * could be but are not limited to:<br/>
         * <table border="0" cellpadding="3" cellspacing="0">
         * <tr><td><c>ErrorCode.EC_NETWORKERROR</c></td>
         *				<td>A networking error has occurred and the conneciton
         *					is nolonger valid.
         *				</td></tr>
         * <tr><td><c>ErrorCode.EC_NOTAUTHORIZED</c></td>
         *				<td>The current logged in user is not authorized to create users.
         *				</td></tr>
         * <tr><td><c>ErrorCode.EC_DOESNOTEXIST</c></td>
         *				<td>The user specified does not exist.
         *				</td></tr>
         * </table>
         * </returns>
         */
        public ErrorCode DeleteUser(string username)
        {
            USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS	parms = new USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS();
            ErrorCode										ret = ErrorCode.EC_NETWORKERROR;

            parms.username = username;
            try {
                output.Write(Safmq.CMD_USER_DELETE);
                parms.Write(output);
                output.Flush();
                ret = getResponseCode();
            } catch (Exception) {
                ret = ErrorCode.EC_NETWORKERROR;
            }
            return ret;
        }
예제 #3
0
        /**
         * <summary>
         * Retrieves a the list of groups the in which the user resides.  The names of the groups are
         * deposited into the <c>List&lt;string&gt; users</c> in the form of <c>string</c>
         * objects.
         * </summary>
         *
         * <param name="username">	The name of the users.</param>
         * <param name="groups">	A List&lt;string&gt; receiving <c>string</c> objects containing
         *      					the group's name.</param>
         *
         * <returns><c>ErrorCode.EC_NOERROR</c> upon success, otherwise errors returned
         * could be but are not limited to:<br/>
         * <table border="0" cellpadding="3" cellspacing="0">
         * <tr><td><c>ErrorCode.EC_NETWORKERROR</c></td>
         *				<td>A networking error has occurred and the conneciton
         *					is nolonger valid.
         *				</td></tr>
         * <tr><td><c>ErrorCode.EC_DOESNOTEXIST</c></td>
         *				<td>The specified user does not exist on the SAFMQ server.
         *				</td></tr>
         * </table>
         * </returns>
         */
        public ErrorCode UserGetGroups(string username, List<string> groups)
        {
            USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS	parms = new USER_DELETE_USER_GET_PERMS_USER_GET_GROUPS_PARAMS();
            ErrorCode										ret = ErrorCode.EC_NETWORKERROR;

            parms.username = username;
            groups.Clear();

            try {
                output.Write(Safmq.CMD_USER_GET_GROUPS);
                parms.Write(output);
                output.Flush();
                ret = getResponseCode();
                if (ret == ErrorCode.EC_NOERROR) {
                    int	nGroups;
                    int	x;
                    byte[] groupname = new byte[Safmq.GROUP_NAME_LENGTH];

                    nGroups = input.ReadInt32();
                    for(x=0;x<nGroups; x++) {
                        input.Read(groupname, 0, groupname.Length);
                        groups.Add(new string(Encoding.UTF8.GetChars(groupname,0,ioutil.length(groupname))));
                    }
                }
            } catch (Exception) {
                ret = ErrorCode.EC_NETWORKERROR;
            }
            return ret;
        }