Reputation: 353
I'm trying to add a user to a group using nuget package Novell.Directory.Ldap.NETStandard, I followed this link - https://github.com/dsbenghe/Novell.Directory.Ldap.NETStandard/blob/master/original_samples/Samples/AddUserToGroup.cs
However I see error - "Error in attribute conversion operation, data 0, v3839"
Creating the user using this nuget package works fine, but adding to group fails. Are there other ways of adding user to group, for ex. find a group by name and add the user. Above sample has multiple steps - adding Group's DN to User's attributes groupMemberShip and securityEquals and then adding User's DN to Group's attributes uniqueMember and equivalentToMe
Upvotes: 1
Views: 968
Reputation: 46
Was stuck with the same issue today, but not much different than with Directoryservices. Here is the modified function which works with Active Directory
public bool AddUserToGroup(LdapConnection conn, System.String userdn, System.String groupdn)
{
// modifications for group
LdapModification[] modGroup = new LdapModification[1];
// Add modifications to modGroup
LdapAttribute member = new LdapAttribute("member", userdn);
modGroup[0] = new LdapModification(LdapModification.Add, member);
try
{
// Modify the group's attributes
conn.Modify(groupdn, modGroup);
System.Console.Out.WriteLine("Modified the group's attribute.");
}
catch (LdapException e)
{
System.Console.Out.WriteLine("Failed to modify group's attributes: " + e.LdapErrorMessage);
doCleanup(conn, userdn, groupdn);
return false;
}
catch (Exception e)
{
Console.WriteLine("Error:" + e.Message);
return false;
}
return true;
}
Upvotes: 3