I am trying to add a new user in SPWeb with "limited access" as roleDefinition. But it shows error. But if i give "full control", read, design i'm able to add the user.
This is my code web.SiteUsers.Add(loginName, string.Empty, displayName, string.Empty);
What is the solution
LimitedAccess is only managed by the system and, as far as I know, cannot be set programmatically. This permission only exists to allow user(s) to traverse the site tree to retrieve content on which they have access.
You can create a custom permission level with nearly no right and assign it to your user if it's what you are looking for or you should update the permission to the relevant value on the targeted locations (items, webs, etc) in your site collection tree, SharePoint will then mark this user as a limited access user in the root site.