An S-layer is a membrane commonly found in gram-positive and gram-negative bacteria, as well as among Archaea. It is composed of protein and glycoprotein. In gram-negative bacteria, the S-layer is directly attached to the outer membrane. In gram-positive bacteria, the S-layer is attached to the peptidoglycan layer. The S-layer protects the cell against ion and pH changes as well as osmotic stress and enzymes. The S-layer may be useful in helping the cell adhere to surfaces and protecting pathogens from phagocytosis. Also helps to mentain the shape and envelope rigidity of some bacterial cells.