@@ -100,19 +100,21 @@ def attempt_login(credential)
100
100
client = RubySMB ::Client . new ( self . dispatcher , username : username , password : password , domain : realm )
101
101
status_code = client . login
102
102
103
- # Windows SMB will return an error code during Session
104
- # Setup, but nix Samba requires a Tree Connect. Try admin$
105
- # first, since that will tell us if this user has local
106
- # admin access. Fall back to IPC$ which should be accessible
107
- # to any user with valid creds.
108
- begin
109
- tree = client . tree_connect ( "\\ \\ #{ host } \\ admin$" )
110
- # Check to make sure we can write a file to this dir
111
- if tree . permissions . add_file == 1
112
- access_level = AccessLevels ::ADMINISTRATOR
103
+ if status_code == WindowsError ::NTStatus ::STATUS_SUCCESS
104
+ # Windows SMB will return an error code during Session
105
+ # Setup, but nix Samba requires a Tree Connect. Try admin$
106
+ # first, since that will tell us if this user has local
107
+ # admin access. Fall back to IPC$ which should be accessible
108
+ # to any user with valid creds.
109
+ begin
110
+ tree = client . tree_connect ( "\\ \\ #{ host } \\ admin$" )
111
+ # Check to make sure we can write a file to this dir
112
+ if tree . permissions . add_file == 1
113
+ access_level = AccessLevels ::ADMINISTRATOR
114
+ end
115
+ rescue Exception => e
116
+ client . tree_connect ( "\\ \\ #{ host } \\ IPC$" )
113
117
end
114
- rescue Exception => e
115
- client . tree_connect ( "\\ \\ #{ host } \\ IPC$" )
116
118
end
117
119
118
120
case status_code . name
0 commit comments