Class: Winevt::EventLog::Session
- Inherits:
-
Object
- Object
- Winevt::EventLog::Session
- Defined in:
- ext/winevt/winevt_session.c,
lib/winevt/session.rb,
ext/winevt/winevt_session.c
Overview
Manage Session information for Windows EventLog.
Defined Under Namespace
Modules: RpcLoginFlag
Instance Method Summary collapse
-
#domain ⇒ String
This method returns domain for remoting access.
-
#domain=(rb_domain) ⇒ Object
This method specifies domain for remoting access.
-
#flags ⇒ Integer
This method returns flags for remoting access.
-
#flags=(rb_flags) ⇒ Object
This method specifies flags for remoting access.
-
#initialize(server, domain = nil, username = nil, password = nil, flags = Winevt::EventLog::Session::RpcLoginFlag::AuthDefault) ⇒ Session
constructor
Initalize Session class.
- #initialize_raw ⇒ Object
-
#password ⇒ String
This method returns password for remoting access.
-
#password=(rb_password) ⇒ Object
This method specifies password for remoting access.
-
#server ⇒ String
This method returns server for remoting access.
-
#server=(rb_server) ⇒ Object
This method specifies server for remoting access.
-
#username ⇒ String
This method returns username for remoting access.
-
#username=(rb_username) ⇒ Object
This method specifies username for remoting access.
Constructor Details
#initialize(server, domain = nil, username = nil, password = nil, flags = Winevt::EventLog::Session::RpcLoginFlag::AuthDefault) ⇒ Session
Initalize Session class.
92 93 94 95 96 97 98 |
# File 'ext/winevt/winevt_session.c', line 92 def initialize(server, domain = nil, username = nil, password = nil) initialize_raw self.server = server self.domain = domain if domain.is_a?(String) self.username = username if username.is_a?(String) self.password = password if password.is_a?(String) end |
Instance Method Details
#domain ⇒ String
This method returns domain for remoting access.
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'ext/winevt/winevt_session.c', line 166
static VALUE
rb_winevt_session_get_domain(VALUE self)
{
struct WinevtSession* winevtSession;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
if (winevtSession->domain) {
return wstr_to_rb_str(CP_UTF8, winevtSession->domain, -1);
} else {
return rb_str_new2("(NULL)");
}
}
|
#domain=(rb_domain) ⇒ Object
This method specifies domain for remoting access.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'ext/winevt/winevt_session.c', line 185
static VALUE
rb_winevt_session_set_domain(VALUE self, VALUE rb_domain)
{
struct WinevtSession* winevtSession;
DWORD len;
VALUE vdomainBuf;
PWSTR wDomain;
Check_Type(rb_domain, T_STRING);
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
len =
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_domain), RSTRING_LEN(rb_domain),
NULL, 0);
wDomain = ALLOCV_N(WCHAR, vdomainBuf, len + 1);
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_domain), RSTRING_LEN(rb_domain),
wDomain, len);
wDomain[len] = L'\0';
winevtSession->domain = _wcsdup(wDomain);
ALLOCV_END(vdomainBuf);
return Qnil;
}
|
#flags ⇒ Integer
This method returns flags for remoting access.
325 326 327 328 329 330 331 332 333 |
# File 'ext/winevt/winevt_session.c', line 325
static VALUE
rb_winevt_session_get_flags(VALUE self)
{
struct WinevtSession* winevtSession;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
return LONG2NUM(winevtSession->flags);
}
|
#flags=(rb_flags) ⇒ Object
This method specifies flags for remoting access.
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'ext/winevt/winevt_session.c', line 358
static VALUE
rb_winevt_session_set_flags(VALUE self, VALUE rb_flags)
{
struct WinevtSession* winevtSession;
EVT_RPC_LOGIN_FLAGS flags = EvtRpcLoginAuthDefault;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
switch(TYPE(rb_flags)) {
case T_SYMBOL:
flags = get_session_rpc_login_flag_from_cstr(RSTRING_PTR(rb_sym2str(rb_flags)));
break;
case T_STRING:
flags = get_session_rpc_login_flag_from_cstr(StringValuePtr(rb_flags));
break;
case T_FIXNUM:
flags = NUM2LONG(rb_flags);
break;
default:
rb_raise(rb_eArgError, "Expected Symbol, String or Fixnum in flags");
}
winevtSession->flags = flags;
return Qnil;
}
|
#initialize_raw ⇒ Object
4 |
# File 'lib/winevt/session.rb', line 4 alias_method :initialize_raw, :initialize |
#password ⇒ String
This method returns password for remoting access.
272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'ext/winevt/winevt_session.c', line 272
static VALUE
rb_winevt_session_get_password(VALUE self)
{
struct WinevtSession* winevtSession;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
if (winevtSession->password) {
return wstr_to_rb_str(CP_UTF8, winevtSession->password, -1);
} else {
return rb_str_new2("(NULL)");
}
}
|
#password=(rb_password) ⇒ Object
This method specifies password for remoting access.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'ext/winevt/winevt_session.c', line 291
static VALUE
rb_winevt_session_set_password(VALUE self, VALUE rb_password)
{
struct WinevtSession* winevtSession;
DWORD len;
VALUE vpasswordBuf;
PWSTR wPassword;
Check_Type(rb_password, T_STRING);
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
len =
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_password), RSTRING_LEN(rb_password),
NULL, 0);
wPassword = ALLOCV_N(WCHAR, vpasswordBuf, len + 1);
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_password), RSTRING_LEN(rb_password),
wPassword, len);
wPassword[len] = L'\0';
winevtSession->password = _wcsdup(wPassword);
ALLOCV_END(vpasswordBuf);
return Qnil;
}
|
#server ⇒ String
This method returns server for remoting access.
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'ext/winevt/winevt_session.c', line 114
static VALUE
rb_winevt_session_get_server(VALUE self)
{
struct WinevtSession* winevtSession;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
if (winevtSession->server) {
return wstr_to_rb_str(CP_UTF8, winevtSession->server, -1);
} else {
return rb_str_new2("(NULL)");
}
}
|
#server=(rb_server) ⇒ Object
This method specifies server for remoting access.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'ext/winevt/winevt_session.c', line 133
static VALUE
rb_winevt_session_set_server(VALUE self, VALUE rb_server)
{
struct WinevtSession* winevtSession;
DWORD len;
VALUE vserverBuf;
PWSTR wServer;
Check_Type(rb_server, T_STRING);
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
len =
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_server), RSTRING_LEN(rb_server),
NULL, 0);
wServer = ALLOCV_N(WCHAR, vserverBuf, len + 1);
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_server), RSTRING_LEN(rb_server),
wServer, len);
winevtSession->server = _wcsdup(wServer);
wServer[len] = L'\0';
ALLOCV_END(vserverBuf);
return Qnil;
}
|
#username ⇒ String
This method returns username for remoting access.
219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'ext/winevt/winevt_session.c', line 219
static VALUE
rb_winevt_session_get_username(VALUE self)
{
struct WinevtSession* winevtSession;
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
if (winevtSession->username) {
return wstr_to_rb_str(CP_UTF8, winevtSession->username, -1);
} else {
return rb_str_new2("(NULL)");
}
}
|
#username=(rb_username) ⇒ Object
This method specifies username for remoting access.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'ext/winevt/winevt_session.c', line 238
static VALUE
rb_winevt_session_set_username(VALUE self, VALUE rb_username)
{
struct WinevtSession* winevtSession;
DWORD len;
VALUE vusernameBuf;
PWSTR wUsername;
Check_Type(rb_username, T_STRING);
TypedData_Get_Struct(self, struct WinevtSession, &rb_winevt_session_type, winevtSession);
len =
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_username), RSTRING_LEN(rb_username),
NULL, 0);
wUsername = ALLOCV_N(WCHAR, vusernameBuf, len + 1);
MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(rb_username), RSTRING_LEN(rb_username),
wUsername, len);
wUsername[len] = L'\0';
winevtSession->username = _wcsdup(wUsername);
ALLOCV_END(vusernameBuf);
return Qnil;
}
|