private ICswUser _InitNewUser(ICswResources Resources, CswNbtResources NbtResources, string UserName, CswNbtObjClassRole Role, string Password = DefaultPassword) { ICswUser Ret = null; if (null != NbtResources && false == string.IsNullOrEmpty(UserName) && null != Role) { //ICswResources IResources = Resources; //CswNbtResources NbtResources = (CswNbtResources) IResources; CswNbtMetaDataObjectClass UserOc = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UserClass); CswNbtMetaDataNodeType UserNt = UserOc.getLatestVersionNodeTypes().FirstOrDefault(); if (null != UserNt) { Ret = (CswNbtObjClassUser)NbtResources.Nodes.makeNodeFromNodeTypeId(UserNt.NodeTypeId, OverrideUniqueValidation : true, OnAfterMakeNode : delegate(CswNbtNode NewNode) { CswNbtObjClassUser NewUser = NewNode; NewUser.UsernameProperty.Text = UserName; NewUser.Role.RelatedNodeId = Role.NodeId; NewUser.PasswordProperty.Password = Password; NewUser.postChanges(ForceUpdate: false); }); _finalize(NbtResources); //Ret = NewUser; } } if (null == Ret) { throw new CswDniException("Could not intialize new user"); } return(Ret); }
private ICswUser _InitUser(ICswResources Resources, CswNbtResources NbtResources, string UserName) { ICswUser Ret = null; if (null != NbtResources && false == string.IsNullOrEmpty(UserName)) { CswNbtObjClassUser NewUser = NbtResources.Nodes.makeUserNodeFromUsername(UserName); Ret = NewUser; } if (null == Ret) { throw new CswDniException("Could not intialize new user"); } return(Ret); }
public CswEnumAuthenticationStatus AuthenticateWithSchema(CswEncryption CswEncryption, CswWebSvcSessionAuthenticateData.Authentication.Request AuthenticationRequest, out ICswUser AuthenticatedUser) { CswNbtSchemaAuthenticationLogic AuthenticationLogic = new CswNbtSchemaAuthenticationLogic(_CswNbtResources); CswNbtObjClassUser UserNode = null; if (AuthenticationRequest.AuthenticationStatus != CswEnumAuthenticationStatus.TooManyUsers) { UserNode = _authorizeUser(CswEncryption, AuthenticationRequest); AuthenticationRequest.AuthenticationStatus = AuthenticationLogic.GetAuthStatus(UserNode); } AuthenticationLogic.LogAuthenticationAttempt(UserNode, AuthenticationRequest); AuthenticatedUser = UserNode; return(AuthenticationRequest.AuthenticationStatus); }