예제 #1
0
        public async Task <bool> UpdateUserInfoAsync(string personDn, string firstName, string lastName,
                                                     string telephone, string mobilephone,
                                                     string email, string street, string zip, string city)
        {
            //"mobile,usertype,givenname,postaladdress,cn,erglobalid,l,erroles,uid,erpersonstatus,mail,erparent,postalcode,objectclass,sn,personnumber"
            //var person = await _personService.lookupPersonAsync(_wsSession, personNumber);

            var updateResult = await _personService.modifyPersonAsync(new modifyPersonRequest
            {
                personDN = personDn,
                session  = WsSession,
                //date = DateTime.Now,
                wsAttrs = new[]
                {
                    CreateWsAttribute(IamUserAttributes.FirstName, firstName),
                    CreateWsAttribute(IamUserAttributes.Surname, lastName),
                    CreateWsAttribute(IamUserAttributes.Telephone, telephone),
                    CreateWsAttribute(IamUserAttributes.CellPhone, mobilephone),
                    CreateWsAttribute(IamUserAttributes.Email, email),
                    CreateWsAttribute(IamUserAttributes.Address, street),
                    CreateWsAttribute(IamUserAttributes.ZipCode, zip),
                    CreateWsAttribute(IamUserAttributes.City, city),
                }
            });

            await _wsRequestService.WaitForCompletion(WsSession, updateResult.modifyPersonReturn.requestId);

            return(updateResult.modifyPersonReturn.status == 0);
        }
예제 #2
0
        public async Task ChangePasswordAsync(string userName, string newPassword)
        {
            var personSession = _ticketProvider.GetWsSession();
            // Search for persons
            var personDn = await GetPersonObjectIdByNameAsync(userName);

            if (string.IsNullOrEmpty(personDn))
            {
                throw new ArgumentNullException(nameof(userName), "User does not exist in IAM system");
            }

            var req = await _personService.synchPasswordsAsync(new synchPasswordsRequest()
            {
                session      = personSession,
                personDN     = personDn,
                password     = newPassword,
                notifyByMail = false
            });

            await _wsRequestService.WaitForCompletion(personSession, req.synchPasswordsReturn.requestId);
        }
예제 #3
0
        public async Task AddUserToOrganizationAsync(UserCore user, CustomerBasicInfo customer, string[] roleIds = null)
        {
            if (roleIds == null)
            {
                roleIds = new string[0];
            }

            var personSearch = _personService.searchPersonsFromRoot(new searchPersonsFromRootRequest
            {
                session  = WsSession,
                filter   = $"(uid={user.UserName})",
                attrList = new string[] { }
            });

            var person = personSearch?.searchPersonsFromRootReturn?.FirstOrDefault();

            if (person == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var userOrganizations = person.attributes?
                                    .FirstOrDefault(a => a.name == "lmorg")?.values?
                                    .Where(r => r != customer.CustomerNo)
                                    .ToList() ?? new List <string>();

            userOrganizations.Add(customer.CustomerNo);
            var newOrgs = userOrganizations.ToArray();

            var addOrgResponse = await _personService.modifyPersonAsync(new modifyPersonRequest
            {
                session  = _ticketProvider.GetWsSession(),
                personDN = person.itimDN,
                wsAttrs  = new[] { new WSAttribute {
                                       name = "lmorg", values = newOrgs
                                   } }
            });

            await _wsRequestService.WaitForCompletion(WsSession, addOrgResponse.modifyPersonReturn.requestId);

            var userOrgRoles = person.attributes?
                               .FirstOrDefault(a => a.name == "lmorgroles")?.values?
                               .Where(r => !r.StartsWith($"{customer.CustomerNo};"))
                               //filter out all roles already in the org
                               .ToList() ?? new List <string>();


            userOrgRoles.AddRange(roleIds.Select(rid => $"{customer.CustomerNo};{rid}"));
            var newRoles = userOrgRoles.ToArray();

            var addRoleResponse = await _personService.modifyPersonAsync(new modifyPersonRequest
            {
                session  = _ticketProvider.GetWsSession(),
                personDN = person.itimDN,
                wsAttrs  = new[] { new WSAttribute {
                                       name = "lmorgroles", values = newRoles
                                   } }
            });

            await _wsRequestService.WaitForCompletion(WsSession, addRoleResponse.modifyPersonReturn.requestId);
        }