An S-layer is a cell 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 outer membrane is absent). The S-layer protects the cell against ion and pH changes as well as osmotic stress and foreign enzymes. The S-layer may be useful in helping the cell adhere to surfaces and protecting pathogens from phagocytosis. It also helps to maintain the shape and envelope rigidity of some bacterial cells.