You are viewing limited content. For full access, please sign in.

Question

Question

SDK: Unable to Add LDAP User To Group

SDK
asked on August 17, 2018

I'm trying to add a legitimate LDAP user to a group, both of which exist on the repository, but I'm getting the error "Trustee not found.  [9012]" upon the AddMembersToGroup().  I'm using the code, below.

Anyone have any advice for me?

   AccountReference acctRef = new AccountReference(userName, _session);
        AccountInfo groupAI = Account.GetInfo(groupName, _session);
        AccountReference groupAR = new AccountReference(groupAI);

        System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
        list.Add(userName);
        IEnumerable<string> newlist = list;
        Account.AddMembersToGroup(groupAR, newlist, _session);

 

0 0

Answer

SELECTED ANSWER
replied on August 17, 2018

Use GroupInfo.LinkWindowsAccount to add non-LF accounts to a LF group:

string ldapUsername = "user@domain";

// Lookup the account by name to get the SID
AccountReference actRef = new AccountReference(ldapUsername, session);

// Retrieve the SID
SecurityIdentifier sid = actRef.ToSecurityIdentifier();

// Add the ldap user to the LF group
GroupInfo lfGroup = (GroupInfo)Account.GetInfo("My LFGroup", session);
lfGroup.LinkWindowsAccount(sid);
lfGroup.Save();

 

0 0
replied on August 20, 2018

Thank you Robert, that did the trick.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.