/// <summary> /// Sets the current user identity. /// </summary> public void SetUserIdentity(IUserIdentity identity) { string methodName = "IOPCSecurityPrivate.Logon"; try { IOPCSecurityPrivate server = BeginComCall <IOPCSecurityPrivate>(methodName, true); if (server != null) { int bAvailable = 0; server.IsAvailablePriv(out bAvailable); if (bAvailable != 0) { bool logoff = true; if (identity != null && identity.TokenType == UserTokenType.UserName) { UserNameSecurityToken securityToken = identity.GetSecurityToken() as UserNameSecurityToken; if (securityToken != null) { server.Logon(securityToken.UserName, securityToken.Password); logoff = false; } } if (logoff) { server.Logoff(); } } } } catch (Exception e) { ComCallError(methodName, e); } finally { EndComCall(methodName); } }
/// <summary> /// Sets the current user identity. /// </summary> public void SetUserIdentity(IUserIdentity identity) { string methodName = "IOPCSecurityPrivate.Logon"; try { IOPCSecurityPrivate server = BeginComCall<IOPCSecurityPrivate>(methodName, true); if (server != null) { int bAvailable = 0; server.IsAvailablePriv(out bAvailable); if (bAvailable != 0) { bool logoff = true; if (identity != null && identity.TokenType == UserTokenType.UserName) { UserNameSecurityToken securityToken = identity.GetSecurityToken() as UserNameSecurityToken; if (securityToken != null) { server.Logon(securityToken.UserName, securityToken.Password); logoff = false; } } if (logoff) { server.Logoff(); } } } } catch (Exception e) { ComCallError(methodName, e); } finally { EndComCall(methodName); } }