Hello there,
I have created a subroutine/stored procedure to have the AD groups automatically synchronized using an SQL Agent job. Initially this job starts up fine (every evening at 20:00), but after some time the job fails with the message below:
Executed as user: {service account}. <msg id="not_authorized_usr_admin"></msg> SQLSTATE 42000] (Error 50000). The step failed.
If I then manually kick off the stored procedure, the job will function correctly again for some time.
Below the stored procedure which is used:
declare sync_ad_groups cursor fast_forward for
select
usr_grp_id, active_directory_grp_name
from iam.dbo.usr_grp
where 1 = 1
and usr_grp_type = 1
open sync_ad_groups
fetch next from sync_ad_groups into @usr_grp_id, @active_directory_grp_name
while @@fetch_status <> -1
begin
if @@fetch_status <> -2
begin
exec iam.dbo.task_import_active_directory_grp
@usr_grp_id = @usr_grp_id ,
@active_directory_grp_name = @active_directory_grp_name ,
@active_directory_domain_name = @active_directory_domain_name ,
@net_bios_domain_name = @net_bios_name ,
@user_name = @user_name ,
@password = @password
end
fetch next from sync_ad_groups into @usr_grp_id, @active_directory_grp_name
end
close sync_ad_groups
deallocate sync_ad_groups
What could be reason of this exception?
Thanks in advance.
Randolph