Beispiel #1
0
        private static FbUserData[] ParseUserData(byte[] buffer, ref int pos)
        {
            ArrayList  users       = new ArrayList();
            FbUserData currentUser = null;
            int        type        = 0;
            int        length      = 0;

            while ((type = buffer[pos++]) != IscCodes.isc_info_end)
            {
                switch (type)
                {
                case IscCodes.isc_spb_sec_username:
                {
                    currentUser = new FbUserData();

                    users.Add(currentUser);

                    length = IscHelper.VaxInteger(buffer, pos, 2);
                    pos   += 2;
                    currentUser.UserName = Encoding.Default.GetString(buffer, pos, length);
                    pos += length;
                }
                break;

                case IscCodes.isc_spb_sec_firstname:
                    length = IscHelper.VaxInteger(buffer, pos, 2);
                    pos   += 2;
                    currentUser.FirstName = Encoding.Default.GetString(buffer, pos, length);
                    pos += length;
                    break;

                case IscCodes.isc_spb_sec_middlename:
                    length = IscHelper.VaxInteger(buffer, pos, 2);
                    pos   += 2;
                    currentUser.MiddleName = Encoding.Default.GetString(buffer, pos, length);
                    pos += length;
                    break;

                case IscCodes.isc_spb_sec_lastname:
                    length = IscHelper.VaxInteger(buffer, pos, 2);
                    pos   += 2;
                    currentUser.LastName = Encoding.Default.GetString(buffer, pos, length);
                    pos += length;
                    break;

                case IscCodes.isc_spb_sec_userid:
                    currentUser.UserID = IscHelper.VaxInteger(buffer, pos, 4);
                    pos += 4;
                    break;

                case IscCodes.isc_spb_sec_groupid:
                    currentUser.GroupID = IscHelper.VaxInteger(buffer, pos, 4);
                    pos += 4;
                    break;
                }
            }
            pos--;

            return((FbUserData[])users.ToArray(typeof(FbUserData)));
        }
		/// <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="AddUser(FbUserData)"]/*'/>
		public void AddUser(FbUserData user)
		{
			if (user.UserName != null && user.UserName.Length == 0)
			{
				throw new InvalidOperationException("Invalid user name.");
			}
			if (user.UserPassword != null && user.UserPassword.Length == 0)
			{
				throw new InvalidOperationException("Invalid user password.");
			}

			// Configure Spb
			this.StartSpb = this.CreateParameterBuffer();

			this.StartSpb.Append(IscCodes.isc_action_svc_add_user);

			this.StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName);
			this.StartSpb.Append(IscCodes.isc_spb_sec_password, user.UserPassword);

			if (user.FirstName != null && user.FirstName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_firstname, user.FirstName);
			}

			if (user.MiddleName != null && user.MiddleName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_middlename, user.MiddleName);
			}

			if (user.LastName != null && user.LastName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_lastname, user.LastName);
			}

			if (user.UserID != 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);
			}

			if (user.GroupID != 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);
			}

			if (user.GroupName != null && user.GroupName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sec_groupname, user.GroupName);
			}

			if (user.RoleName != null && user.RoleName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
			}

			// Start execution
			this.StartTask();

			this.Close();
		}
Beispiel #3
0
        /// <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="AddUser(FbUserData)"]/*'/>
        public void AddUser(FbUserData user)
        {
            if (user.UserName != null && user.UserName.Length == 0)
            {
                throw new InvalidOperationException("Invalid user name.");
            }
            if (user.UserPassword != null && user.UserPassword.Length == 0)
            {
                throw new InvalidOperationException("Invalid user password.");
            }

            // Configure Spb
            this.StartSpb = this.CreateParameterBuffer();

            this.StartSpb.Append(IscCodes.isc_action_svc_add_user);

            this.StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName);
            this.StartSpb.Append(IscCodes.isc_spb_sec_password, user.UserPassword);

            if (user.FirstName != null && user.FirstName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_firstname, user.FirstName);
            }

            if (user.MiddleName != null && user.MiddleName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_middlename, user.MiddleName);
            }

            if (user.LastName != null && user.LastName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_lastname, user.LastName);
            }

            if (user.UserID != 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);
            }

            if (user.GroupID != 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);
            }

            if (user.GroupName != null && user.GroupName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sec_groupname, user.GroupName);
            }

            if (user.RoleName != null && user.RoleName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
            }

            // Start execution
            this.StartTask();

            this.Close();
        }
Beispiel #4
0
        /// <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="DeleteUser(FbUserData)"]/*'/>
        public void DeleteUser(FbUserData user)
        {
            if (user.UserName != null && user.UserName.Length == 0)
            {
                throw new InvalidOperationException("Invalid user name.");
            }

            // Configure Spb
            this.StartSpb = this.CreateParameterBuffer();

            this.StartSpb.Append(IscCodes.isc_action_svc_delete_user);

            this.StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName);

            if (user.RoleName != null && user.RoleName.Length > 0)
            {
                this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
            }

            // Start execution
            this.StartTask();

            this.Close();
        }
		/// <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="DeleteUser(FbUserData)"]/*'/>
		public void DeleteUser(FbUserData user)
		{
			if (user.UserName != null && user.UserName.Length == 0)
			{
				throw new InvalidOperationException("Invalid user name.");
			}

			// Configure Spb
			this.StartSpb = this.CreateParameterBuffer();

			this.StartSpb.Append(IscCodes.isc_action_svc_delete_user);

			this.StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName);

			if (user.RoleName != null && user.RoleName.Length > 0)
			{
				this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
			}

			// Start execution
			this.StartTask();

			this.Close();
		}
		public void DeleteUser()
		{
			FbSecurity securitySvc = new FbSecurity();

			securitySvc.ConnectionString = this.BuildServicesConnectionString(false);

			FbUserData user = new FbUserData();
			
			user.UserName = "******";
						
			securitySvc.DeleteUser(user);
		}
		public void AddUserTest()
		{
			FbSecurity securitySvc = new FbSecurity();

			securitySvc.ConnectionString = this.BuildServicesConnectionString(false);

			FbUserData user = new FbUserData();
			
			user.UserName 		= "******";
			user.UserPassword 	= "******";
			
			securitySvc.AddUser(user);
		}
		private static FbUserData[] ParseUserData(byte[] buffer, ref int pos)
		{
			ArrayList users = new ArrayList();
			FbUserData currentUser = null;
			int type = 0;
			int length = 0;

			while ((type = buffer[pos++]) != IscCodes.isc_info_end)
			{
				switch (type)
				{
					case IscCodes.isc_spb_sec_username:
						{
							currentUser = new FbUserData();

							users.Add(currentUser);

							length = IscHelper.VaxInteger(buffer, pos, 2);
							pos += 2;
							currentUser.UserName = Encoding.Default.GetString(buffer, pos, length);
							pos += length;
						}
						break;

					case IscCodes.isc_spb_sec_firstname:
						length = IscHelper.VaxInteger(buffer, pos, 2);
						pos += 2;
						currentUser.FirstName = Encoding.Default.GetString(buffer, pos, length);
						pos += length;
						break;

					case IscCodes.isc_spb_sec_middlename:
						length = IscHelper.VaxInteger(buffer, pos, 2);
						pos += 2;
						currentUser.MiddleName = Encoding.Default.GetString(buffer, pos, length);
						pos += length;
						break;

					case IscCodes.isc_spb_sec_lastname:
						length = IscHelper.VaxInteger(buffer, pos, 2);
						pos += 2;
						currentUser.LastName = Encoding.Default.GetString(buffer, pos, length);
						pos += length;
						break;

					case IscCodes.isc_spb_sec_userid:
						currentUser.UserID = IscHelper.VaxInteger(buffer, pos, 4);
						pos += 4;
						break;

					case IscCodes.isc_spb_sec_groupid:
						currentUser.GroupID = IscHelper.VaxInteger(buffer, pos, 4);
						pos += 4;
						break;
				}
			}
			pos--;

			return (FbUserData[])users.ToArray(typeof(FbUserData));
		}