working on it ...

Filters

Explore Public Snippets

Sort by

Found 312 snippets matching: privileges

    public by cghersi  2081  0  6  0

    Grant privileges to SQL user in MySql

    This is how to allow a user to see a particular schema in MySQL
    GRANT ALL PRIVILEGES ON MySchema.* TO 'myuser'@'localhost' WITH GRANT OPTION;
    GRANT ALL PRIVILEGES ON MySchema.* TO 'myuser'@'%' WITH GRANT OPTION;

    public by p.kontalis  2694  4  6  0

    Mysql user privileges

    mysql grant user privileges
    CREATE USER 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';
    GRANT ALL PRIVILEGES ON `DATABASE`.* TO 'USERNAME'@'IP';
    FLUSH PRIVILEGES;
    
    # USERNAME: Username
    # IP: The Address for remote access OR localhost for local access. Can be used the % symbol as wildcard
    # PASSWORD: Password without encription
    # DATABASE: The database that we need the user

    public by UdeF  2184  0  5  0

    Check administrator privileges

    This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits.
    @rem ----[ This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits]-------
    echo OFF
    NET SESSION >nul 2>&1
    IF %ERRORLEVEL% EQU 0 (
        ECHO Administrator PRIVILEGES Detected! 
    ) ELSE (
       echo.
       echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########
       echo This script must be run as administrator to work properly!  
       echo If you're seeing this after clicking on a start menu icon, then right click on the shortcut and select "Run As Administrator".
       echo ##########################################################
       echo.
       PAUSE
       EXIT /B 1
    )
    @echo ON

    public by mmcculley  1943  1  4  1

    To export all MySQL user privileges run following script.

    To export all MySQL user privileges run following script.: exportMySQLUsers
    # Note : Replace {host_name}, {user_name} and {password} with your values.
    
    mysql -h {host_name} -u {user_name} -p{password} -Ne "select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from user;" mysql | mysql -h {host_name} -u {user_name} -p{password} | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
    
    
    

    public by NassimB  1906  0  5  0

    mysql user privileges / grant tables

    1.Create user in mysql.user
    2.UPDATE user SET Password=PASSWORD('password') WHERE User='user_name';
    3.FLUSH PRIVILEGES;
    4.GRANT ALL ON database.table TO user_name IDENTIFIED BY 'p@$$vvord';

    public by cghersi  3993  17  6  1

    How to create a new user within PLAT.ONE

    This fragment creates a new user on PLAT.ONE using the Java SDK. It can be called by mirrored services, as well as from an external client, provided that the calling client has ADMIN privileges.
    import java.util.ArrayList;
    import java.util.List;
    
    import com.abodata.plat1.network.addressing.MacAddress;
    import com.abodata.plat1.networkInfo.protocolType;
    import com.abodata.plat1.utils.Plat1CommonUtils;
    import com.abodata.plat1.velocity.client.IPlatoneAPI;
    import com.abodata.plat1.ws.velocity.IProxyLogicalNode;
    import com.abodata.plat1.ws.velocity.IProxyPhysicalNode;
    import com.abodata.plat1.ws.velocity.IProxyPlatUser;
    import com.abodata.plat1.ws.velocity.proxy.ClientProxyPlatUser;
    import com.abodata.plat1.ws.velocityInfo.PlatUserLevel;
    import com.abodata.plat1.ws.velocityInfo.SecKeyFormat;
    import com.abodata.plat1.ws.velocityInfo.UserIdentProperties;
    
    public class UserManager {
    
    	public static int createUser(String username, int appGardenID, List<MacAddress> visibleDevices,
    			List<Integer> visibleClusters) throws Exception {
    		// 1. Fill the info of the user:
    		IProxyPlatUser newUser = new ClientProxyPlatUser();
    		newUser.setUsername(username);
    		newUser.setIdentProperties(new UserIdentProperties("com",
    				username, "rd", "MyCompany", "600 Hansen Way", "Palo Alto",
    				"CA", "US"));
    		newUser.setPassword("supersecret");
    		newUser.setEmail(username + "@mycompany.com");
    		newUser.setPrivateKeyFormat(SecKeyFormat.pem);
    		newUser.setPublicKeyFormat(SecKeyFormat.pem);
    		newUser.setUserLevel(PlatUserLevel.USER);
    		
    		// 2. Save onto the DB and retrieve the new user ID:
    		newUser = HelloWorldServiceImpl.getSUAPI().DB_AddPlatUser(newUser);
    		if (newUser == null)
    			return -1;
    		int newUserID = newUser.getId();
    		
    		// 3. Assign the user to a specific App Garden:
    		if (!HelloWorldServiceImpl.getSUAPI().DB_AddAppGardenUser(appGardenID, newUserID))
    			return -1;
    		
    		// 4. Tune the security policies of the new user with the given App Garden:
    		HelloWorldServiceImpl.getSUAPI().DB_ModifyPlatUserSecPolicy(appGardenID, newUserID, false, true);
    
    		// 5. (optional) make the given devices visible to the user:
    		if (!Plat1CommonUtils.isNullOrEmpty(visibleDevices)) {
    			
    			// 5.1. retrieve the IDs of logical nodes and networks to be made visible to the user:
    			IPlatoneAPI api = HelloWorldServiceImpl.getAPI();
    			List<Integer> logNodeIds = new ArrayList<Integer>();
    			List<Integer> netIds = new ArrayList<Integer>();
    			for (MacAddress mac : visibleDevices) {
    				IProxyPhysicalNode device = api.DB_GetPhysicalNode(mac, protocolType.MQTT);
    				if (device == null)
    					continue;
    				List<IProxyLogicalNode> logNodes = api.DB_PhysicalNode_GetLogicalNodes(device.getId());
    				
    				// add the network if not yet added:
    				if (!netIds.contains(device.getNetworkId()))
    					netIds.add(device.getNetworkId());
    				
    				// add the logical nodes:
    				if (!Plat1CommonUtils.isNullOrEmpty(logNodes)) {
    					for (IProxyLogicalNode ln : logNodes) {
    						logNodeIds.add(ln.getId());
    					}
    				}
    			}
    			
    			// 5.2. add the network(s) to the set of visible entities of the user:
    			if (!HelloWorldServiceImpl.getAPI().DB_AddAvailNetworks4User(appGardenID, newUserID, netIds))
    				return -1;
    			
    			// 5.3. add the logical node(s) to the set of visible entities of the user:
    			if (!HelloWorldServiceImpl.getAPI().DB_AddAvailNodes4User(appGardenID, newUserID, logNodeIds))
    				return -1;
    		}
    		
    		// 6. (optional) make the given clusters visible to the user:
    		if (!Plat1CommonUtils.isNullOrEmpty(visibleClusters)) {
    			if (!HelloWorldServiceImpl.getAPI().DB_AddAvailClusters4User(appGardenID, newUserID, visibleClusters, false, false))
    				return -1;
    		}
    		
    		return newUserID;
    	}
    }
    
    // This goes into your OSGI-INF/component.xml
    	<reference
    	   	interface="com.abodata.plat1.velocity.client.su.IPlatoneSUAPI"
    	   	cardinality="1..n"
    	   	policy="dynamic"
    	   	bind="setSUAPI"
    	   	unbind="removeSUAPI"/> 
    	<reference
    	   	interface="com.abodata.plat1.velocity.client.IPlatoneAPI"
    	   	cardinality="1..n"
    	   	policy="dynamic"
    	   	bind="setAPI"
    	   	unbind="removeAPI"/> 
    	   	
    // This is the fragment in your activator class:
    	static AtomicReference<IPlatoneSUAPI> suapiMan = new AtomicReference<IPlatoneSUAPI>();
    	
    	void setSUAPI(IPlatoneSUAPI arg) {
    		DSUtils.setRef(log, suapiMan, arg, IPlatoneSUAPI.class, this.getClass());
    	}
    	
    	void removeSUAPI(IPlatoneSUAPI arg) {
    		DSUtils.removeRef(log, suapiMan, arg, IPlatoneSUAPI.class, this.getClass());
    	}
    	
    	static IPlatoneSUAPI getSUAPI() {
    		return DSUtils.get(log, suapiMan, true);
    	}
    	
    	static AtomicReference<IPlatoneAPI> apiMan = new AtomicReference<IPlatoneAPI>();
    	
    	void setAPI(IPlatoneAPI arg) {
    		DSUtils.setRef(log, apiMan, arg, IPlatoneAPI.class, this.getClass());
    	}
    	
    	void removeAPI(IPlatoneAPI arg) {
    		DSUtils.removeRef(log, apiMan, arg, IPlatoneAPI.class, this.getClass());
    	}
    	
    	static IPlatoneAPI getAPI() {
    		return DSUtils.get(log, apiMan, true);
    	}          

    external by davejamesmiller  446  0  3  0

    MySQL: Find users with no privileges

    MySQL: Find users with no privileges: no-privileges.sql
    SQL
    -- Note: This only checks global permissions and database permissions, not table permissions.
    -- Tested on MySQL 5.6 - other versions may have a different set of global permissions.
    
    SELECT mysql.user.*
    FROM mysql.user
    LEFT JOIN mysql.db
        ON mysql.db.Host = user.Host
        AND mysql.db.User = user.User
    WHERE mysql.db.Db IS NULL
        AND mysql.user.Select_priv = FALSE
        AND mysql.user.Insert_priv = FALSE
        AND mysql.user.Update_priv = FALSE
        AND mysql.user.Delete_priv = FALSE
        AND mysql.user.Create_priv = FALSE
        AND mysql.user.Drop_priv = FALSE
        AND mysql.user.Reload_priv = FALSE
        AND mysql.user.Shutdown_priv = FALSE
        AND mysql.user.Process_priv = FALSE
        AND mysql.user.File_priv = FALSE
        AND mysql.user.Grant_priv = FALSE
        AND mysql.user.References_priv = FALSE
        AND mysql.user.Index_priv = FALSE
        AND mysql.user.Alter_priv = FALSE
        AND mysql.user.Show_db_priv = FALSE
        AND mysql.user.Super_priv = FALSE
        AND mysql.user.Create_tmp_table_priv = FALSE
        AND mysql.user.Lock_tables_priv = FALSE
        AND mysql.user.Execute_priv = FALSE
        AND mysql.user.Repl_slave_priv = FALSE
        AND mysql.user.Repl_client_priv = FALSE
        AND mysql.user.Create_view_priv = FALSE
        AND mysql.user.Show_view_priv = FALSE
        AND mysql.user.Create_routine_priv = FALSE
        AND mysql.user.Alter_routine_priv = FALSE
        AND mysql.user.Create_user_priv = FALSE
        AND mysql.user.Event_priv = FALSE
        AND mysql.user.Trigger_priv = FALSE
        AND mysql.user.Create_tablespace_priv = FALSE;
    
    

    external by mbn18  57  0  1  0

    Cant revoke from PUBLIC privileges

    Cant revoke from PUBLIC privileges: gistfile1.txt
    I did this:
    
    REVOKE CONNECT ON DATABASE test FROM PUBLIC; (also tried on template1)
    REVOKE ALL ON ALL TABLES IN SCHEMA public FROM PUBLIC;
    
    ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON TABLES FROM PUBLIC;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON SEQUENCES FROM PUBLIC;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM PUBLIC;
    
    New users can do select, create table & etc after given the CONNECT privilege
    
    I guess I am doing something wrong
    
    

    external by nzbart  45  0  1  0

    Determine whether user has administrative privileges in PowerShell

    Determine whether user has administrative privileges in PowerShell: IsAdministrator.ps1
    (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
    
    

    external by Gleb Averchuk  45  0  1  0

    PSQL change tables owner and grant major privileges to user

    PSQL change tables owner and grant major privileges to user: psql-owner.sh
    #!/bin/sh
    
    if [ "$#" -ne 2 ]; then
      echo "Usage $0 new_owner target_db"
      exit 1
    fi
    
    $NEW_OWNER=$1
    $TARGET_DB=$2
    
    psql -c "GRANT INSERT ON ALL TABLES IN SCHEMA public TO ${NEW_OWNER};" $TARGET_DB
    psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${NEW_OWNER};" $TARGET_DB
    psql -c "GRANT UPDATE ON ALL TABLES IN SCHEMA public TO ${NEW_OWNER};" $TARGET_DB
    psql -c "GRANT DELETE ON ALL TABLES IN SCHEMA public TO ${NEW_OWNER};" $TARGET_DB
    psql -c "GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO ${NEW_OWNER};" $TARGET_DB
    
    for tbl in `psql -qAt -c "SELECT tablename FROM pg_tables WHERE schemaname = 'public';" $TARGET_DB`; do
      psql -c "ALTER TABLE $tbl OWNER TO $NEW_OWNER" $TARGET_DB
    done
    
    for tbl in `psql -qAt -c "SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = 'public';" $TARGET_DB`; do
      psql -c "ALTER TABLE $tbl OWNER TO $NEW_OWNER" $TARGET_DB
    done
    
    for tbl in `psql -qAt -c "SELECT table_name FROM information_schema.views WHERE table_schema = 'public';" $TARGET_DB`; do
      psql -c "ALTER TABLE $tbl OWNER TO $NEW_OWNER" $TARGET_DB
    done
    
    
    
    • Public Snippets
    • Channels Snippets