File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ public interface IAgDatabase
3030
3131 void CopyLogins ( IEnumerable < LoginProperties > logins ) ;
3232 IEnumerable < LoginProperties > AssociatedLogins ( ) ;
33+ void DropLogin ( LoginProperties login ) ;
34+ void DropAllLogins ( ) ;
3335 }
3436
3537
@@ -137,7 +139,18 @@ public void CopyLogins(IEnumerable<LoginProperties> logins)
137139
138140 public IEnumerable < LoginProperties > AssociatedLogins ( )
139141 {
140- return _listener . Primary . Database ( Name ) . Users . Where ( u => u . Login != null ) . Select ( u => u . Login . Properties ( ) ) ;
142+ return _listener . Primary . Database ( Name ) . Users . Where ( u => u . Login != null && u . Login . Name != "sa" )
143+ . Select ( u => u . Login . Properties ( ) ) ;
144+ }
145+
146+ public void DropLogin ( LoginProperties login )
147+ {
148+ _listener . ForEachAgInstance ( server => server . DropLogin ( login ) ) ;
149+ }
150+
151+ public void DropAllLogins ( )
152+ {
153+ foreach ( var loginProp in AssociatedLogins ( ) ) DropLogin ( loginProp ) ;
141154 }
142155
143156 /// <summary>
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ public void Dispose()
5151 SqlConnection ? . Dispose ( ) ;
5252 }
5353
54+ public void DropLogin ( LoginProperties login )
55+ {
56+ _server . Logins [ login . Name ] . DropIfExists ( ) ;
57+ }
58+
5459 /// <summary>
5560 /// Parses the AG name from the connection's DataSource.
5661 /// </summary>
You can’t perform that action at this time.
0 commit comments