Can. 984 §2 answers your question:
Can. 983 §1. The sacramental seal is inviolable; therefore it is absolutely forbidden for a confessor to betray in any way a penitent in words or in any manner [e.g., by signs] and for any reason.
Can. 984 §1. A confessor is prohibited completely from using knowledge acquired from confession to the detriment of the penitent even when any danger of revelation is excluded.
§2. A person who has been placed in authority cannot use in any manner for external governance the knowledge about sins which he has received in confession at any time.
Can. 985 The director of novices and his associate and the rector of a seminary or other institute of education are not to hear the sacramental confessions of their students residing in the same house unless the students freely request it in particular cases.
(Also, Can. 983 §1 and Can. 984 §1 forbids using knowledge to betray or defame the penitent. Confessors actually can reveal good things about the penitent obtained in confession; cf. the example of St. Catherine of Siena's confessor, Bl. Raymond of Capua, O.P..)
Canonist Dom Augustine explains:
It is the use of sacramental knowledge that is forbidden. Thus a superior, whose knowledge is based solely on confession, cannot make use of it for purposes of external government; for instance, he cannot remove a minor official from office; he cannot remove a pastor who accused himself of a sin which would render him unfit for continuing as pastor; he cannot forbid him the sacraments, if publicly approached, even at the risk of sacrilege; he is not allowed to treat him unkindly or to withdraw from him his confidence or a post of trust; he may not change a previous arrangement after hearing confession, even though this arrangement had not yet been made public.
If a superior has reliable knowledge obtained outside the confessional, he may, of course, make use of it, provided that this extra-sacramental knowledge is the motive of his action. If this were not the case, the superior could not, for instance, remove a priest from the office of confessor for occult crimes known to him outside of confession.
Seminaries and religious institutes often have unwritten rules that if a seminarian or novice cannot break the habit of mortal sin (e.g., against the 6th commandment) for a period of more than, say, one year, then the seminarian or novice should not continue and is most likely not called to the priesthood or religious life. Such a rule really cannot be enforced unless the sin is public, so the rule exists more for the sake of the seminarians and novices.
For example, Benedict Ashley, O.P., writes in his autobiography ch. 13:
In my years as a confessor of seminarians our practice was to tell a brother who confessed masturbation that if he had not been free from this sin for a year before taking final vows, he should leave the Order. In general I know that during their eight student years, when hormones must have been at their most raging, almost all seminarians achieved this absolute chastity and indeed the great majority practiced it from the time of their simple vows.
A traditional seminary expelled a seminarian for being "offensively effeminate". Clearly, that knowledge was public and not obtained in confession.