Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Create user throwing exception S.DS.AM

Last post 03-05-2010, 6:19 PM by joe. 1 replies.
Sort Posts: Previous Next
  •  03-05-2010, 3:04 PM 7926

    Create user throwing exception S.DS.AM

    Thought I would try my hand at using the s.ds.am to create a user. Seems to be fairly straight forward but this block of code seems to always throw an error...
    InnerException: Make sure you have sufficient privileges to access this resource.
    InnerException: If you are attempting to access a file, make sure it is not ReadOnly.

    I supplied a valid admin name and password. So I'm confused as to which context it is using to generate the user. Is it running under the application thread or a different thread under the specified credentials? However it throw the exception, it still completes the creation process and does in fact create the account with all the properties set on it.

    This is my first attempt to create a user using the s.ds.am so any help would be appreciated.

    Thanks in advance for anyhelp.

    value for domain = "xxxx.xxx.xx.us"
    value for destination = "ou=xxxx,ou=yyyyy,ou=zzzzz,dc=aaaa, dc=bbb, dc=cc, dc=dd"


    try
                Dim ipc As New PrincipalContext(ContextType.Domain, domain, destination, ContextOptions.Negotiate, admin, adminpwd)
                Dim user As UserPrincipal
                user = New UserPrincipal(ipc,samaccountname, "ASdf1234", True)
                user.Name = name
                user.EmailAddress = mail
                user.DisplayName = displayname
                user.SamAccountName = samaccountname
                user.HomeDirectory = homedirectory
                user.HomeDrive = homedrive
                user.Surname = sn
                user.GivenName = givenname
                user.Description = description
                user.UserPrincipalName = userprincipalname
                user.Save(ipc)
    catch ex as exception

  •  03-05-2010, 6:19 PM 7929 in reply to 7926

    Re: Create user throwing exception S.DS.AM

    If the admin user creds you supplied are sufficient, it should work as shown.

    You might consider binding with the same creds using SDS and reading the allowedChildClassesEffective attribute (use refreshcache to add it to the cache explicitly). It will return an array of strings with the names of the objectClasses of the classes you have permissions to create in that container. It is a good check on permissions.

View as RSS news feed in XML