The Department of Defense has agreed to change the database it uses for military recruitment efforts to better protect the privacy of millions of high school students nationwide, a civil liberties group announced Tuesday.

In settling a lawsuit brought last year by the New York Civil Liberties Union on behalf of six high schoolers, the government agreed it will no longer disseminate student information to law enforcement, intelligence and other agencies and will stop collecting student Social Security numbers, the group said in a statement.

It said it will also limit to three years the time it retains student information and will clarify procedures by which students can block the military from entering information about them in its database.

Last year's lawsuit claimed the department was flouting a 1982 military recruitment law that specifies that it refrain from collecting information on students under 17, that it store the information for no more than three years and that the information be kept private, the lawsuit said.

The current database includes information on 16-year-olds, is storing the information for five years and is being shared with law enforcement and other agencies, the lawsuit said.

Military officials have said they have about 30 million names in the database. The Pentagon said in 2005 the list includes high school students ages 16-18 and college students, and includes such information as the students' Social Security numbers, gender and race.

The government published the changes in the Federal Register on Tuesday before they were announced by the NYCLU.

Yusill Scribner, a spokeswoman for government lawyers who worked on the case, said the government had no comment.